NginxProxyManager / nginx-proxy-manager

Docker container for managing Nginx proxy hosts with a simple, powerful interface
https://nginxproxymanager.com
MIT License
22.02k stars 2.54k forks source link

Bad Gateway Error #1334

Open Seralius opened 3 years ago

Seralius commented 3 years ago

Used Docker Stack The Used Docker-Stack was the Docker-Compose from the Website at https://nginxproxymanager.com/guide/#quick-setup

Checklist

Describe the bug

I'm getting an Bad Gateway Error when trying to setup an Proxy-Host for External Websites (specifically when using HTTPS)

Nginx Proxy Manager Version

v2.2.3

To Reproduce Steps to reproduce the behavior:

  1. See Pictures at Screenshots

Expected behavior

I can successfully reverse-proxy the given Website

Screenshots

Here is an Example where i tried to setup an Proxy-Host for https://nginxproxymanager.com:443: image image image To test if the Container can access the Website, i did an Curl of the Exact URL inside of the Container, which is successful: image

Operating System

Debian Server

Additional Information

jc21 commented 3 years ago

This is an interesting problem. I haven't really tried forwarding to hosts outside of my own network, until now.

I inspected the nginx logs for the proxy host, and it looks like this is a Nginx problem not one to do with the configuration of this host.

2021/08/19 22:56:13 [crit] 90998#90998: *27749 connect() to [2600:9000:20ec:1800:2:8434:1380:93a1]:443 failed (99: Cannot assign requested address) while connecting to upstream, client: 192.168.0.38, server: example.jc21.supernerd.pro, request: "GET /favicon.ico HTTP/1.1", upstream: "https://[2600:9000:20ec:1800:2:8434:1380:93a1]:443/favicon.ico", host: "example.jc21.supernerd.pro", referrer: "http://example.jc21.supernerd.pro/"

2021/08/19 22:56:13 [warn] 90998#90998: *27749 upstream server temporarily disabled while connecting to upstream, client: 192.168.0.38, server: example.jc21.supernerd.pro, request: "GET /favicon.ico HTTP/1.1", upstream: "https://[2600:9000:20ec:1800:2:8434:1380:93a1]:443/favicon.ico", host: "example.jc21.supernerd.pro", referrer: "http://example.jc21.supernerd.pro/"

so it appears that nginx is trying to access the host on the ipv6 address directly instead of a hostname? 🤷

The proxy host config is essentially this:

server {
  set $forward_scheme https;
  set $server         "nginxproxymanager.com";
  set $port           443;

  listen 80;
  listen [::]:80;

  server_name example.jc21.supernerd.pro;

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

  location / {
    add_header       X-Served-By $host;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Scheme $scheme;
    proxy_set_header X-Forwarded-Proto  $scheme;
    proxy_set_header X-Forwarded-For    $remote_addr;
    proxy_set_header X-Real-IP          $remote_addr;
    proxy_pass       $forward_scheme://$server:$port;
  }
}

and I don't see any problems with the configuration.

I found this problem related to the error, and tried to apply the solution but has not worked for me.

jc21 commented 3 years ago

I just tried a different upstream host that does not have an ipv6 address and I don't get any errors in the logs, but the upstream server is returning 501 not implemented so it's probably the upstream server not happy with the proxied request.

github-actions[bot] commented 6 months ago

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

harryyang2024 commented 3 months ago

I got same error : [ipv6 address]:443 failed (99: Cannot assign requested address), when the target host that only have a public ipv6 address. So I wonder if the container don't support ipv6. After I add option network_mode: host in docker compose file, I didn't get the error. Hope it will be helpful!