NginxProxyManager / nginx-proxy-manager

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

Having issues migrating functional nginx config into Nginx Proxy Manager #3131

Open miversen33 opened 10 months ago

miversen33 commented 10 months ago

Checklist

Describe the bug

I have the following location defined in an nginx.conf which functions exactly as expected

location /portainer/ {
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Real-Ip $remote_addr;
    proxy_set_header X-Forwarded-For $remote_add_x_forwarded_for;
    proxy_pass https://hostname.domain:9443/;
}

I figured it would be as easy as adding a new proxy host in Nginx Proxy Manager, adding the /portainer/ location and setting the various proxy_header variables in the advanced section of the location. However, when I add literally any of the proxy_set_header lines above, the location throws a 400. I cannot see anything really "useful" in the container logs for nginx-proxy-manager.

Am I missing something?

Nginx Proxy Manager Version

v2.10.4

To Reproduce Steps to reproduce the behavior:

  1. Create new proxy host
  2. Add a location
  3. Add proxy_set_header X-Real-IP $remote_addr; (for example) to the advanced section of the location
  4. Save the location
  5. Navigate a new tab to the location
  6. Observe 400

Expected behavior

I would expect the proxy_set_header values to be respected. Additionally, if there is a configuration error occurring, some form of notification seems like a plus

Screenshots

I can provide these if needed

Operating System

Additional context

Running under compose using the following docker compose script

version: '3.8'
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: unless-stopped
    ports:
      - '80:80' # Public HTTP Port
      - '443:443' # Public HTTPS Port
      - '81:81' # Admin Web Port
      - '5090-6000:5090-6000' # Snag up any other ports we might want to proxy to
    volumes:
      - /opt/docker/npm/:/data

The only thing any of the log files emits on save is

[warn] 141#141: could not build optimal proxy_headers_hash, you should increase either proxy_headers_hash_max_size: 512 or proxy_headers_hash_bucket_size: 64; ignoring proxy_headers_hash_bucket_size

And on hitting the created endpoint, the following 2 things are logged (along with lots of repeated 500s of trying to get the favicon)

==> proxy-host-2_access.log <==
[15/Aug/2023:17:03:34 +0000] - 400 400 - GET http hostname.domain "/portainer/" [Client 10.0.139.109] [Length 25] [Gzip -] [Sent-to hostname.domain] "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0" "-"

==> fallback_error.log <==
2023/08/15 17:03:34 [warn] 1471#1471: 512 worker_connections are not enough, reusing connections
miversen33 commented 10 months ago

Is there more information that I need to provide to get some kind of feedback about what I may be doing incorrectly here?

edsonsbj commented 9 months ago

Lista

  • Você puxou e encontrou o erro com a imagem do docker? jc21/nginx-proxy-manager:latest
    • Sim
  • Tem certeza de que não está usando a imagem docker de outra pessoa?
    • Sim
  • Você já pesquisou por problemas semelhantes (abertos e fechados)?
    • Sim

Descreva o bug

Eu tenho o seguinte local definido em um que funciona exatamente como esperadonginx.conf

location /portainer/ {
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Real-Ip $remote_addr;
    proxy_set_header X-Forwarded-For $remote_add_x_forwarded_for;
    proxy_pass https://hostname.domain:9443/;
}

Eu imaginei que seria tão fácil quanto adicionar um novo host proxy no Nginx Proxy Manager, adicionando o local e definindo as várias variáveis proxy_header na seção do local. No entanto, quando eu adiciono literalmente qualquer uma das linhas acima, o local lança um 400. Não consigo ver nada realmente "útil" nos logs de contêiner para nginx-proxy-manager./portainer/``advanced``proxy_set_header

Estou sentindo falta de alguma coisa?

Nginx Proxy Manager Versão

v2.10.4

Para reproduzir etapas para reproduzir o comportamento:

  1. Criar novo host proxy
  2. Adicionar uma localização
  3. Adicionar (por exemplo) à seção avançada do localproxy_set_header X-Real-IP $remote_addr;
  4. Salve o local
  5. Navegar em uma nova guia até o local
  6. Observe 400

Comportamento esperado

Espero que os valores sejam respeitados. Além disso, se houver um erro de configuração ocorrendo, alguma forma de notificação parece uma vantagemproxy_set_header

Imagens

Eu posso fornecê-los, se necessário

Sistema Operacional

  • RHEL 8,8
  • Docker versão 24.0.5, build ced0996

Contexto adicional

Executando sob composição usando o seguinte script de composição docker

version: '3.8'
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: unless-stopped
    ports:
      - '80:80' # Public HTTP Port
      - '443:443' # Public HTTPS Port
      - '81:81' # Admin Web Port
      - '5090-6000:5090-6000' # Snag up any other ports we might want to proxy to
    volumes:
      - /opt/docker/npm/:/data

A única coisa que qualquer um dos arquivos de log emite ao salvar é

[aviso] 141#141: não foi possível construir proxy_headers_hash ideal, você deve aumentar proxy_headers_hash_max_size: 512 ou proxy_headers_hash_bucket_size: 64; ignorando proxy_headers_hash_bucket_size

E ao atingir o ponto de extremidade criado, as 2 coisas a seguir são registradas (junto com muitos 500s repetidos de tentar obter o favicon)

==> proxy-host-2_access.log <==
[15/Aug/2023:17:03:34 +0000] - 400 400 - GET http hostname.domain "/portainer/" [Client 10.0.139.109] [Length 25] [Gzip -] [Sent-to hostname.domain] "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0" "-"

==> fallback_error.log <==
2023/08/15 17:03:34 [warn] 1471#1471: 512 worker_connections are not enough, reusing connections

It's simpler than you think, you just need to add a new location in custom locations in the location field /portainer/ and in the Forward Hostname / IP* fieldyour ip followed by / and the port number.

Because nginx itself already does the rest when saving the configuration

location /portainer/ {
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Real-Ip $remote_addr;
    proxy_set_header X-Forwarded-For $remote_add_x_forwarded_for;
    proxy_pass https://hostname.domain:9443/;
}
github-actions[bot] commented 1 month ago

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