[英]502 Bad Gateway on reverse proxy nodejs using Nginx with https
I've seen similar questions like this asked a lot but the errors they're getting don't seem to be a 502 bad gateway just an issue with setting up the server. 我看到类似的问题问了很多,但它们遇到的错误似乎不是502错误的网关,而仅仅是设置服务器的问题。
So I'm running a nodejs
application using pm2
to keep the process running. 所以我运行
nodejs
使用应用程序pm2
保持进程运行。
In my nginx
/sites-available/default
file I have... 在我的
nginx
/sites-available/default
文件中,我有...
server {
listen 80;
listen [::]:80 default_server;
}
server {
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
ssl on;
ssl_certificate /etc/letsencrypt/live/server.name.comfullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/server.name.com/privkey.pem;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
#proxy_pass https://0.0.0.0:4444;
#proxy_http_version 1.1;
#proxy_set_header Upgrade $http_upgrade;
#proxy_set_header Connection 'upgrade';
#proxy_set_header Host $host;
#proxy_cache_bypass $http_upgrade;
}
location /demo {
proxy_pass https://0.0.0.0:4444;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
So I've got my certificate setup and I can hit my server on https
and see everything i've placed in the index.html
file. 因此,我已经完成了证书设置,可以在
https
访问我的服务器,并查看在index.html
文件中放置的所有内容。 Within the index.html
file there's a <a href="https://server.name.com/demo">Link</a>
that forwards me to /demo
where in my location
block I'm trying to proxy the port 4444
which my application is running on. 在
index.html
文件中,有一个<a href="https://server.name.com/demo">Link</a>
将我转发到/demo
,在我的location
块中,我尝试代理该端口我的应用程序正在运行的4444
。
I'm getting a 502 Bad Gateway
error when I hit the page. 进入页面时,我收到
502 Bad Gateway
错误。
I'm a bit lost on the steps to debug this. 我对调试它的步骤有些迷惑。 Any help?
有什么帮助吗?
Is on 0.0.0.0:4444 realy a https service running and not http? 是在0.0.0.0:4444上运行的是https服务而不是http吗? Anyway i would recommend not to use ssl behind the reverese-proxy because of performance issues and there is no need for encryption.
无论如何,由于性能问题,我建议不要在reverese-proxy后面使用ssl,并且不需要加密。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.