2012-11-24 26 views
25

我想實現的nginx重寫規則下列情況與代理Nginx的重寫規則通過

請求:

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

應該被重定向到:

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

我想這沒有運氣:

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

對nginx執行這種重寫的正確方法是什麼?

回答

44

您的重寫聲明是錯誤的。

右側的$ 1表示匹配部分中的一個組(由paratheses表示)。

嘗試:

rewrite ^/Shep.ElicenseWeb/(.*) /$1 break; 
+0

你可以嘗試: >位置/ { 改寫^ /(。*)/Shep.ElicenseWeb/$1突破; proxy_pass http://127.0.0.1:82; } – biolinh