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

127
Visualizações
nginx reverse proxy location

I would like to have nginx set as a reverse proxy following these rules:

http://www.example.com/home/{x}/{y}//index.html?zvalue={z}&a=1&b=2&c=3 etc...

proxied to

http://www.example2.com/home/{x}/{y}/{z}/index.html?a=1&b=2&c=3 etc...

So basically the query string value of {z} is set as part of the path. All other query params such as a,b,c,d etc need to be forwarded as shown in the example.

What are the configuration I need to put in nginx?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Manipulating the query string is best done using a map with named captures. See this document for details.

For example:

map $request_uri $proxy {
    default 0;
    ~*^(?<prefix>/home/.*)/index.html\?zvalue=(?<zvalue>[^&]+)&(?<suffix>.*)$ $prefix/$zvalue/index.html?$suffix;
}

Obviously the regular expression needs to match your exact requirements, and the above was just a proof of concept.

You can use the variable with a proxy_pass statement, within an if block, within an existing location. See this document for details.

For example:

location / {
    proxy_pass http://example.com;
    if ($proxy) { proxy_pass http://example.com$proxy; }
}

Any request which is not subject to the map will be passed transparently by the first proxy_pass statement.

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