I'm trying to implement nginx rewrite rules for the following situation


Should be redirected to:


I tried this with no luck:

location /Shep.ElicenseWeb/ {
    rewrite ^/Shep.ElicenseWeb/ /$1 last;
    proxy_pass http://localhost:82;

What is the correct way to perform such a rewrite for nginx ?


Your rewrite statement is wrong.

The $1 on the right refers to a group (indicated by parentheses) in the matching section.


rewrite ^/Shep.ElicenseWeb/(.*) /$1 break;
location /Shep.ElicenseWeb/ {
    proxy_pass http://localhost:82/;

You do not need rewrite at all. Just a / in the end of proxy_pass.

Please, read the docs: http://nginx.org/r/proxy_pass

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.