1

I have my nginx proxy pass config setup as follows:

location /try-me {
   proxy_pass https://some-domain.com?id=true&zone=false
} 

This works fine. But the problem is when someone from the browser tries

https://mywebsite.com/try-me?ping=true&foo=bar

The final URL that gets created after the proxy_pass is:

https://some-domain.com?id=true&zone=false?ping=true&foo=bar

The query parameter formation is completely incorrect. How can I make sure that Nginx appends any query parameters forwarded in the following manner:

id=true&zone=false&ping=true&foo=bar

1 Answer 1

1

It may be better to use rewrite...break rather than trying to get proxy_pass to do it properly.

For example:

location /try-me {
    rewrite ^ /?id=true&zone=false break;
    proxy_pass https://some-domain.com;
}

The rewrite directive will append the original parameters correctly. See this document for details.

In the above example, any URI that begins with /try-me will be rewritten to / with the adjusted query string.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .