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

334
Visualizações
Nginx accept trailing slash or no trailing slash in proxy_pass

I'm running into the following issue where I would like to be able to access a proxy passed location (React/NextJs webApp in a hosted docker container) from a home website with a trailing slash and without a trailing slash.

Currently, when I hit:

http://my-website.com/test # this works

But when I hit:

http://my-website.com/test/ # this fails with a 404

I'd like to be able to hit both of these urls. What am I missing?

   ### Default Server ###
    server {
        listen 80;
        root /usr/site;
        if ($http_x_forwarded_proto = "http") {
            return 301 https://$host$request_uri;
        }
        location ~/test(.*)$ {
                set $upstream_endpoint http://$docker_container_url;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection 'upgrade';
                proxy_pass $upstream_endpoint$1/;
                proxy_set_header    Host    $host;
                proxy_cache_bypass  $http_upgrade;
        }
    }
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

After long experiments we came to this solution:

  location ~ ^/test(?:/(.*))?$ {
    # some directives here
    proxy_pass http://nginx_docker_container_url/$1;
    # some directives here
  }

needed to pass everything after /test to app, with or without trailing slash it should be handled correctly

over 4 years ago · Santiago Trujillo Relatório
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