这是我正在努力完成.....我试图设置一个反向代理服务器在我的开发机器上使用nginx,并在本地不同本地端口上主持三个流星应用程序。我希望我的nginx根据虚拟目录重定向请求...像localhost/App1会重定向到localhost:3010,localhost/App2会到localhost:3011。这些应用程序将需要使用流星身份的微服务(第三APP)进行身份验证和应用程序将需要使用像本地主机/鉴定者重定向未授权的用户Nginx无法加载流星包:获取404错误
作为第一步,我有这样的设置: 我想在本地部署Nginx上的app1 Meteor应用。我用“流星建立”构建了应用程序,并将内容移到了我的根目录下的Nginx/html。一旦我通过nginx端口(localhost:81)浏览应用程序,我无法加载任何流星包,但可以加载应用程序文件。该应用程序本身是在本地主机上运行:3000
下面是错误
Error screenshot : Chrome console
我能够浏览我创建的资源文件,如todo.js,单独
localhost:81/app/template.todo1.js?979b20f66caf126704c250fbd29ce253c6cb490e
但我无法浏览到流星包文件
localhost:81/packages/global-imports.js?af67437fd606dadafb22ec5e8bfc6ca8314a60ad
因为它返回404
下面是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;
}
}
}
任何帮助表示赞赏,因为我有这个问题,因为昨天
你误会了一些东西。你应该将任何*移动到你的nginx根目录下。也许你正在尝试使用nginx作为代理(这是一种常用的方式),但即使这样做也没有必要。请在你的问题中解释你正在努力完成什么(现在只是描述你做了什么,哪些不起作用,但不是你为什么这么做以及最终目标是什么)。 –
这是我正在尝试完成.....我试图设置一个反向代理服务器在我的开发机器上使用nginx,并在本地不同的本地端口上主持三个流星应用程序。我希望我的nginx根据虚拟目录重定向请求...像localhost/App1会重定向到localhost:3010,localhost/App2会到localhost:3011。这些应用程序需要使用Meteor Identity微服务(第三方应用程序)进行身份验证,并且应用程序需要使用像localhost/Iden这样的方式来重定向未经身份验证的用户。希望这是明确的 – Adi
如果反向代理是你想要的,那么我会建议看redbird(https://github.com/OptimalBits/redbird)。用这个创建一个反向代理比用nginx更简单。我始终按照您描述的方式使用它(一个主机,多个流星项目),并且它非常易于设置。 –