0
我曾經見過類似的問題,但問題很多,但他們得到的錯誤似乎不是一個502錯誤的網關,只是設置服務器的一個問題。502使用Nginx與https的反向代理nodejs上的錯誤網關
所以我正在運行nodejs
應用程序使用pm2
來保持進程運行。
在我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;
}
}
所以,我有我的證書安裝,我可以打https
我的服務器和看到的一切,我已經放在index.html
文件。在index.html
文件中,有一個<a href="https://server.name.com/demo">Link</a>
,它將我轉發到/demo
,在我的location
塊中,我試圖代理我的應用程序正在運行的端口4444
。
當我打開頁面時,出現502 Bad Gateway
錯誤。
我在調試這個步驟有點失落。任何幫助?
你應該看看錯誤日誌(通常在'/ var/log/nginx /'中),也許試試'127.0.0.1:4444'而不是'0.0.0.0:4444'。 –