Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!