使用代理传递的Nginx重写规则 [英] Nginx rewrite rule with proxy pass
本文介绍了使用代理传递的Nginx重写规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试针对以下情况实施nginx重写规则
I'm trying to implement nginx rewrite rules for the following situation
请求:
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执行这种重写的正确方法是什么?
What is the correct way to perform such a rewrite for nginx ?
推荐答案
您的重写语句错误.
右边的$ 1表示匹配部分中的一个组(用复数表示).
The $1 on the right refers to a group (indicated by paratheses) in the matching section.
尝试:
rewrite ^/Shep.ElicenseWeb/(.*) /$1 break;
这篇关于使用代理传递的Nginx重写规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文