[GH-ISSUE #3961] Nginx Proxy Manager "502 Bad Gateway- openresty" #2591

Open
opened 2026-02-26 07:36:07 +03:00 by kerem · 3 comments
Owner

Originally created by @MouadR01 on GitHub (Aug 27, 2024).
Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/3961

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.

Originally created by @MouadR01 on GitHub (Aug 27, 2024). Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/3961 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.
Author
Owner

@zaigham commented on GitHub (Aug 27, 2024):

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;
<!-- gh-comment-id:2313279500 --> @zaigham commented on GitHub (Aug 27, 2024): 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; ```
Author
Owner

@hilalkukm commented on GitHub (Feb 24, 2025):

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.

<!-- gh-comment-id:2677782977 --> @hilalkukm commented on GitHub (Feb 24, 2025): 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.
Author
Owner

@github-actions[bot] commented on GitHub (Dec 19, 2025):

Issue is now considered stale. If you want to keep it open, please comment 👍

<!-- gh-comment-id:3673184874 --> @github-actions[bot] commented on GitHub (Dec 19, 2025): Issue is now considered stale. If you want to keep it open, please comment :+1:
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nginx-proxy-manager-NginxProxyManager#2591
No description provided.