Nginx rewrite issue

Paul paul at
Sun Feb 20 17:50:08 UTC 2022

On 2022-02-20 8:17 a.m., Dr_tux wrote:
> Hello,
> I want to write a rewrite like http://url/index.php?target=server1 and
> http://url/target=server1 in Nginx and I want to use it in reverse proxy.
> This is possible in AWS, but how can I do it in Nginx?
> I tried as follows. Not worked.
> location = /index.html?target=server1 {
>    proxy_pass http://server1;
> }
> location = /index.html?target=server2 {
>    proxy_pass http://server2;
> }

What do your error logs show?

Maybe the '=' after 'location' is superfluous?  Please refer to the 
manual at>.

And for more info on using wildcards in 'location', please see 

nginx documentation is pretty good, so start there.  If you still have 
problems after "read the manual" full details of your server setup and 
errors logged would be helpful for others to try and help you.

HTH -- Paul

More information about the nginx mailing list