使用代理传递的 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 ?
推荐答案
你的重写语句是错误的.
Your rewrite statement is wrong.
右边的 $1 指的是匹配部分中的一个组(用括号表示).
The $1 on the right refers to a group (indicated by paratheses) in the matching section.
试试:
rewrite ^/Shep.ElicenseWeb/(.*) /$1 break;
这篇关于使用代理传递的 Nginx 重写规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文