Nginx重写规则与代理传递

我正在试图为以下情况实现nginx重写规则

请求:

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

应该redirect到:

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

我试过这个没有运气:

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

什么是正确的方式来执行这样的重写nginx?

你的重写声明是错误的。

右侧的$1表示匹配部分中的一个组(由圆括号表示)。

尝试:

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

你根本不需要rewrite 。 只是/proxy_pass结束。

请阅读文档: http : //nginx.org/r/proxy_pass