iawegfib
iawegfib

Reputation: 101

Nginx Proxy Manager 502 Bad Gateway error only on https mode

I have a problem with my Nginx Proxy Manager and HTTPS. My Nginx Proxy Manager runs on docker. And my PiHole redirects my domain (sub.domain.de) with a custom dns record back to my server (on Port 80) where Nginx Proxy Manager is running. The Proxy Manager is configured to use the Ports of the docker container I want connect to (for exaple 192.168.178.35:6595).

I get this error:

2022/01/09 11:43:57 [error] 1636#1636: *21857 SSL_do_handshake() failed (SSL: error:1408F10B:SSL routines:ssl3_get_record:wrong version number) while SSL handshaking to upstream, client: 172.17.0.1, server: sub.domain.de, request: "GET / HTTP/2.0", upstream: "https://192.168.178.35:6595/", host: "sub.domain.de"

My domain has a valid Let's Encrypt certificate which also works, but only if I set the Proxy Manager to http and force ssl. But if I say https, it gives me the error "502 Bad Gateway". With Https I mean this: Nginx Proxy Manager Config Picture

Here is my Nginx Proxy Manger config for this domain example.

# ------------------------------------------------------------
# sub.domain.de
# ------------------------------------------------------------

server {
  set $forward_scheme https;
  set $server         "192.168.178.35";
  set $port           6595;

  listen 80;
listen [::]:80;

listen 443 ssl http2;
listen [::]:443 ssl http2;

  server_name sub.domain.de;

  # Let's Encrypt SSL
  include conf.d/include/letsencrypt-acme-challenge.conf;
  include conf.d/include/ssl-ciphers.conf;
  ssl_certificate /etc/letsencrypt/live/npm-10/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/npm-10/privkey.pem;


  access_log /data/logs/proxy-host-19_access.log proxy;
  error_log /data/logs/proxy-host-19_error.log warn;

  location / {

    # Proxy!
    include conf.d/include/proxy.conf;
  }

  # Custom
  include /data/nginx/custom/server_proxy[.]conf;
}

Upvotes: 2

Views: 10470

Answers (1)

Viktor Kainz
Viktor Kainz

Reputation: 41

To use HTTPS with Nginx Proxy Manager you just have to select the certificate in the SSL tab. The Scheme option in the Details tab, that you have set to https, has to be http, because the host you forward to (192.168.178.35:6595) has no SSL certificate. The certificate is only on the proxy.

Upvotes: 4

Related Questions