Nginx Proxy Manager "502 Bad Gateway- openresty"
I've recently set up NPM for some servers on my backend and everything seems to be working just fine for most except for a couple servers that seem to return a "502 Bad Gateway" errors even when I'm sure the scheme is correct and and the port is active.
When I try to execute a curl command from within my docker container, it works just fine and the server responds.
Here's the error I managed to get from the error log: "[error] 667#667: *1150 SSL_do_handshake() failed (SSL: error:0A00042E:SSL routines::tlsv1 alert protocol version:SSL alert number 70) while SSL handshaking to upstream,"
Any ideas how to fix this? I've hit a dead end. Thank you.
I tried to change the resolution from an IP Address one to an FQDN one by modifying the "hosts" file on my reverse proxy server since I noticed that when using the IP Address, my server returns a "404 Not Found" error.
What I tried to do so far is try a handshake using the two versions of TLS (v1.2 and v1.3) and what I've noticed compared to the other servers, the server I'm having an issue with only accepts a TLSv1.3 handshake. Taking this a step further, I added a line within my NPM config to specify the usage of TLSv1.3 "ssl_protocols TLSv1.3;" yet it didn't work.
Are you using multiple domains in a single proxy config? eg. domain.com www.domain.com
If so, try adding this into advanced nginx config:
proxy_ssl_name $host;
proxy_ssl_server_name on;
i have same problem, my setup is :
- Portainer join same network with NPM (bridge driver)
- Portainer version 2.27.0 LTS
- NPM version 2.12.3
- Create dummy nginx web server with port 9001 expose (same network with portainer and NPM)
When i try to add proxy list to NPM and specify port 9001 inside Forward Port and Forward Hostname / IP, i fill container name, the result is 502 Bad Gateway. Then i check inside nginx proxy manager log "/data/log/proxy-host-1_error.log" appear error below :
2025/02/24 04:57:00 [error] 476#476: *591 connect() failed (111: Connection refused) while connecting to upstream, client: 172.x.x.x, server: test1.example.com, request: "GET / HTTP/2.0", upstream: "http://172.18.0.5:9001/", host: "test1.example.com", referrer: "http://x.x.x.x:81/"
From above error, i analyze if the docker gateway won't redirect to container exposed port, then i change Forward Port with port 80, and finally it works.