我无法使用以https和NGINX作为代理的流星雨将流星应用程序(以下简称“ myApp”)部署到生产中。特别是,我认为我在配置正确的端口和/或路径时遇到麻烦。
部署在大多数方面都起作用。它运行在具有mongohq(现在为compose.io)数据库的数字海洋小滴上。My mup setup
,mup reconfig
(现在在mup.json文件上多次运行)和mup deploy
带有流星的命令均未报告任何错误。如果我在数字海洋中进入我的ubuntu环境并运行status myApp
它的报告myApp start/running, process 10049
,并且在检查mongohq数据库时,可以看到myApp的预期集合已创建并植入了种子。在此基础上,我认为该应用程序可以正常运行。
我的问题是我无法找到它访问该站点,并且没有使用NGINX服务器的经验,我无法确定我是否在做一些非常基础和错误的事情来设置端口和转发。
我在下面复制了我的NGINX配置文件和mup.json文件的相关部分。
我对以下设置的预期行为是,如果流星应用程序在mup.json中的端口3000上侦听,则该应用程序应该在我访问该站点时出现。实际上,如果我将mup.json的env.PORT设置为3000,则在访问该站点时,我的浏览器会告诉我存在重定向循环。如果我将Mup的env.PORT更改为80,或将env.PORT完全保留,则会收到一条502 Bad Gateway
消息-这是可以预期的,因为myApp应该在localhost:3000上侦听,并且我不希望在其他任何地方找到任何东西。
感谢所有帮助。
"env": {
"PORT": 3000,
"NODE_ENV": "production",
"ROOT_URL": "http://myApp.com",
"MONGO_URL": // working ok, not reproduced here,
"MONGO_OPLOG_URL": // working ok I think,
"MAIL_URL": // working ok
}
server_tokens off;
# according to a digital ocean guide i followed here, https://www.digitalocean.com/community/tutorials/how-to-deploy-a-meteor-js-application-on-ubuntu-14-04-with-nginx, this section is needed to proxy web-socket connections
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# HTTP
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name myApp.com;
# redirect non-SSL to SSL
location / {
rewrite ^ https://$server_name$request_uri? permanent;
}
}
# HTTPS
server {
listen 443 ssl spdy;
# this domain must match Common Name (CN) in the SSL certificate
server_name myApp.com;
root html;
index index.html index.htm;
ssl_certificate /etc/nginx/ssl/tempcert.crt;
ssl_certificate_key /etc/nginx/ssl/tempcert.key;
ssl_stapling on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 5m;
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'long string I didn't reproduce here'
add_header Strict-Transport-Security "max-age=31536000;";
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
另请注意,SSL证书已配置且可以正常工作,因此我认为这与端口,路径和转发的配置方式有关。我不知道重定向循环来自哪里。
对于将来遇到此问题的任何人,我都可以通过force-ssl
从捆绑的流星应用程序中删除软件包来解决问题。显然force-ssl和NGINX代理是冗余的,或者如果一起使用会导致过多的重定向。我找不到的资料中没有对此进行详细记录。
如果有一种配置支持将force-ssl和用于某些目的的代理一起使用,并且比完全删除该软件包更可取,请发布,因为我很想知道。谢谢。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句