Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

332
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda