我使用Nginx在Ubuntu 14.04上部署了我的Meteor应用程序。我收到的错误似乎与websocket配置有关,特别是
在我的开发机器上一切正常,服务器工作正常,我可以连接多个客户端(浏览器) - 所有这些都在同一台机器上。但是一旦我使用Nginx部署托管的Ubuntu并尝试从远程本地连接,它就会在第一次连接后停止工作。
这是我的nginx配置:
server_tokens off;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80 ;
server_name my-server.net;
root /var/www/appRoot/;
index index.html index.htm;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_read_timeout 150;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Nginx访问日志:
==> /var/log/nginx/access.log <==
<local-public-ip> - - [15/Jun/2016:05:12:39 -0400] "GET / HTTP/1.1" 200 598 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36"
<local-public-ip> - - [15/Jun/2016:05:12:39 -0400] "GET /a25b83093e0a4c316f170b184b33fabceb024100.css?meteor_css_resource=true HTTP/1.1" 304 0 "http://lice.net/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36"
<local-public-ip> - - [15/Jun/2016:05:12:39 -0400] "GET /704ef5bcce37e3c58ad691371641883b2f9199cb.js?meteor_js_resource=true HTTP/1.1" 304 0 "http://lice.net/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36"
<local-public-ip> - - [15/Jun/2016:05:12:40 -0400] "GET /sockjs/info?cb=ea7eki4rlg HTTP/1.1" 200 89 "http://lice.net/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36"
<local-public-ip> - - [15/Jun/2016:05:13:20 -0400] "GET /sockjs/info?cb=7wm0hgbigi HTTP/1.1" 499 0 "http://lice.net/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36"
<local-public-ip> - - [15/Jun/2016:05:13:28 -0400] "GET /sockjs/info?cb=i764h9t6j0 HTTP/1.1" 499 0 "http://lice.net/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36"
我认为这个错误是由于nginx配置,特别是nginx和浏览器客户端之间的socketjs连接,或者是从nginx到meteor app或三者的正确代理。
编辑:不确定这是否相关,但服务器应用是在git pull之后使用“Meteor build”命令在服务器上构建的。