Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

Request:

http://192.168.64.76/Shep.ElicenseWeb/Public/OutputDocuments.ashx?uinz=12009718&iinbin=860610350635 

Should be redirected to:

http://localhost:82/Public/OutputDocuments.ashx?uinz=12009718&iinbin=860610350635 

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 ?

share|improve this question
up vote 1 down vote accepted

Your rewrite statement is wrong.

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

Try:

rewrite ^/Shep.ElicenseWeb/(.*) /$1 break;
share|improve this answer
    
Using rewrite for this task is cumbersome and ineffective way. – VBart Dec 1 '12 at 3:49
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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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