Node.js Nginx PM2 NodeJS带SSL的反向代理提供HTTP 504
曾经有一段美好的时光,我为三个NodeJs,socket.ioAPI做了一个很好的配置,它们运行在同一个ubuntu16.4ltsvps服务器上,带有PM2,用于进程管理,Nginx,用于对三个不同的子域进行反向代理 My已成功安装来自的SSL证书让我们加密,并且所有子域都来自同一个域(比如example.com),应该重定向到https 当我尝试为非NodeJs应用程序(PHP/laravel)添加第四个子域时,反向代理不再被传递,不幸的是,我没有旧Nginx配置的备份 现在,我正试图恢复我的VPS与三个旧的NodeJs应用程序的协调,但它给了我504网关超时时间Nginx 这是我的配置,我认为是相同的旧配置: 这个配置在chrome上运行良好,但我正在尝试从移动和桌面应用程序访问我的API 更新以获取更多信息。 Nginx、NodeJs和PM2没有给出任何错误。原木是干净的。这是我在检查请求时得到的结果 当套接字请求时,它会成功:(两者都Node.js Nginx PM2 NodeJS带SSL的反向代理提供HTTP 504,node.js,ssl,nginx,socket.io,pm2,Node.js,Ssl,Nginx,Socket.io,Pm2,曾经有一段美好的时光,我为三个NodeJs,socket.ioAPI做了一个很好的配置,它们运行在同一个ubuntu16.4ltsvps服务器上,带有PM2,用于进程管理,Nginx,用于对三个不同的子域进行反向代理 My已成功安装来自的SSL证书让我们加密,并且所有子域都来自同一个域(比如example.com),应该重定向到https 当我尝试为非NodeJs应用程序(PHP/laravel)添加第四个子域时,反向代理不再被传递,不幸的是,我没有旧Nginx配置的备份 现在,我正试图恢复我的
wss://
和https://
)
当其他人请求时,它失败:
我还想指出的是,每个sub都安装了SSL,应用程序稳定,在本地服务器上运行,没有任何问题。我解决了问题,它不在而不是Nginx,而不是PM2,而不是Nodejs也不在SSL中,都在我部署的应用程序中。Mongodb的过程中出现问题使他无法自动启动。因此,应用程序接受第一个请求,因为它不需要数据库干预,并在超时后拒绝登录请求,因为应用程序已经崩溃,但PM2重新启动它,Nginx保持子域对请求开放 FF:因此,如果您经过这里,您可能需要检查您的应用程序环境。例如:SGBD、R/W权限、API
希望这可以帮助任何有类似问题的人。我解决了问题,问题不在不是Nginx,不是PM2,不是Nodejs也不在SSL中,都在我部署的应用程序中。Mongodb的过程中出现问题使他无法自动启动。因此,应用程序接受第一个请求,因为它不需要数据库干预,并在超时后拒绝登录请求,因为应用程序已经崩溃,但PM2重新启动它,Nginx保持子域对请求开放 FF:因此,如果您经过这里,您可能需要检查您的应用程序环境。例如:SGBD、R/W权限、API 希望这能帮助任何有类似问题的人
# HTTP — redirect all traffic to HTTPS
server {
listen 80;
listen [::]:80 default_server ipv6only=on;
return 301 https://$host$request_uri;
}
# App1 from port 3000 to sub1.exemple.com
server {
# Enable HTTP/2
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name sub1.exemple.com;
# Use the Let’s Encrypt certificates
ssl_certificate
/etc/letsencrypt/live/sub1.exemple.com/fullchain.pem;
ssl_certificate_key
/etc/letsencrypt/live/sub1.exemple.com/privkey.pem;
# Include the SSL configuration from cipherli.st
include snippets/ssl-params.conf;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-NginX-Proxy true;
proxy_ssl_session_reuse off;
proxy_set_header Host $http_host;
proxy_cache_bypass $http_upgrade;
proxy_pass http://localhost:3000/;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
# App2 from port 4000 to sub2.exemple.com
server {
# Enable HTTP/2
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name sub2.exemple.com;
# Use the Let’s Encrypt certificates
ssl_certificate
/etc/letsencrypt/live/sub2.exemple.com/fullchain.pem;
ssl_certificate_key
/etc/letsencrypt/live/sub2.exemple.com/privkey.pem;
# Include the SSL configuration from cipherli.st
include snippets/ssl-params.conf;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-NginX-Proxy true;
proxy_ssl_session_reuse off;
proxy_set_header Host $http_host;
proxy_cache_bypass $http_upgrade;
proxy_pass http://localhost:4000/;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
# App2 from port 5000 to sub3.exemple.com
server {
# Enable HTTP/2
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name sub3.exemple.com;
# Use the Let’s Encrypt certificates
ssl_certificate
/etc/letsencrypt/live/sub3.exemple.com/fullchain.pem;
ssl_certificate_key
/etc/letsencrypt/live/sub3.exemple.com/privkey.pem;
# Include the SSL configuration from cipherli.st
include snippets/ssl-params.conf;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-NginX-Proxy true;
proxy_ssl_session_reuse off;
proxy_set_header Host $http_host;
proxy_cache_bypass $http_upgrade;
proxy_pass http://localhost:5000/;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}