Here is what i am trying to accomplish..... i am trying to setup a reverse proxy server using nginx on my dev machine and host three meteor apps locally on diffrent local port. I want my nginx to redirect requests based on the virtual directory...something like localhost/App1 would redirect to localhost:3010 and localhost/App2 would to localhost:3011. These apps will need to use Meteor Identity micro service (third app) for authentication and the apps will need to use something like localhost/Iden to redirect unauthenticated users
As a first step i have this Setup: I am trying to deploy app1 Meteor app on Nginx locally. I have build the app with "meteor build" and moved the content to Nginx/html where my root is. Once i browse the app through nginx port (localhost:81) I am not able to load any meteor packages but able to load the app files. The app itself is running on localhost:3000
Below is the error
Error screenshot : Chrome console
I am able to browse the resource files that i created, such as todo.js, individually
localhost:81/app/template.todo1.js?979b20f66caf126704c250fbd29ce253c6cb490e
but i am NOT able to browse to meteor packages files
localhost:81/packages/global-imports.js?af67437fd606dadafb22ec5e8bfc6ca8314a60ad
as it returns 404
Below is my config from nginx
#user nginx;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
server {
listen 0.0.0.0:81;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location ~* "^/[a-z0-9]{60}\.(css|js)$" {
root /app1/bundle/programs/server;
access_log off;
expires max;
}
location ~ "^/packages" {
root /app1/bundle/programs/server;
access_log off;
}
location ~ ^/(images/|img/|javascript/|js/|css/|stylesheets/|flash/|media/|static/|robots.txt|humans.txt|favicon.ico) {
root /app1/bundle/programs/server;
access_log off;
expires max;
}
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
#proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
}
location /app2 {
proxy_pass http://127.0.0.1:3010;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
#proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
Any help appreciated as i am struggling with this issue since yesterday
If all you want is a reverse proxy then I recommend using redbird :
npm install redbird
And then, for instance, if you have two meteor apps running locally on ports 3000 and 4000:
proxy.js:
var proxy = require('redbird')({port: 80});
proxy.register("myfirstapp.com", "http://localhost:3000");
proxy.register("mysecondapp.com", "http://localhost:4000");
and then run:
sudo node proxy.js
Note that it doesn't matter whether the meteor apps are running from a bundle or still using meteor
. But of course the former is advisable for production.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.