Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

138
Visualizações
Nginx proxy while reserving path
http {

    server {
        listen              4443 ssl;
        server_name         {{hostname}};
        port_in_redirect off;

        ssl_certificate     /etc/nginx/ssl/server.crt;
        ssl_certificate_key /etc/nginx/ssl/server.key;

        location / {
            # https://stackoverflow.com/questions/32845674/setup-nginx-not-to-crash-if-host-in-upstream-is-not-found/32846603#32846603
            resolver 127.0.0.1 valid=30s;
            proxy_pass http://app1:8080;
        }
    }

    server {
        listen              4444 ssl;
        server_name         X.{{hostname}};
        port_in_redirect off;

        ssl_certificate     /etc/nginx/ssl/server.crt;
        ssl_certificate_key /etc/nginx/ssl/server.key;

        location / {
            resolver 127.0.0.1 valid=30s;
            proxy_pass http://app1:8080/my/path/;
        }
    }

}

# http://nginx.org/en/docs/stream/ngx_stream_ssl_preread_module.html
# https://stackoverflow.com/questions/34741571/nginx-tcp-forwarding-based-on-hostname/40135151#40135151

stream {

    upstream app1 {
        server 127.0.0.1:4443;
    }


    server {
        listen 0.0.0.0:443;
        proxy_connect_timeout 10s;
        proxy_timeout 5m;

        proxy_pass $target;
        ssl_preread on;
    }


    access_log  /var/log/nginx/access.log basic;
    error_log  /var/log/nginx/error.log error;
}

This is my nginx configuration. This is part of a docker-compose setup. I proxy requests sent to https://hostname to the app1 container successfully.

Now my goal is to send requests sent to https://X.hostname to the app1 container, however to a different path.

For example:

Client sends request to https://A.hostname Nginx forwards it to https://app1/my/path/

However the path is not being preserved, it's just forwarding it to https://app1 Tried many different solutions available online, and none worked.

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda