Ian*_*kem 12 regex wordpress nginx url-rewriting haproxy
我想问一下HAProxy如何根据URL的部分来帮助路由请求.
为了概述我的设置,我有HAProxy机器和两个后端:
用例:
我希望根据URL路由请求:
博客访问URL是" / server/blog/lang/articlexx ",因此我必须将原始客户端请求重写为该格式 - 这基本上是切换"blog"和"lang".
从我如何理解配置文档和网上的一些帖子,我可以使用reqrep/reqirep来更改请求HTTP标头,然后再将其传递给后端.如果这是正确的,那么这个配置应该工作:
frontend vFrontLiner
bind x.x.x.x:x
mode http
option httpclose
default_backend iis_website
# the switch: x/lang/blog -? x/blog/lang
reqirep ^/(.*)/(blog)/(.*) /if\2/\1/\3
acl blog path_beg -i /lang/blog/
use_backend blog_website if blog
backend blog_website
mode http
option httpclose
cookie xxblogxx insert indirect nocache
server BLOG1 x.x.x.x:80 cookie s1 check inter 5s rise 2 fall 3
server BLOG2 x.x.x.x:80 cookie s2 check inter 5s rise 2 fall 3 backup
Run Code Online (Sandbox Code Playgroud)
问题: blog_website后端收到的请求仍然是原始URL"x/lang/blog".
我可能在正则表达式部分遗漏了一些东西,但我主要担心的是我的理解是否正确使用reqirep.我将不胜感激任何帮助.
非常感谢.
你的正则表达式是错误的,你假设服务器在请求路径中.要匹配标头中的请求路径,请使用以下正则表达式:
reqrep ^([^\ ]*)\ /lang/blog/(.*) \1\ /blog/lang/\2
Run Code Online (Sandbox Code Playgroud)
您也可以使用reqirep,但这仅在您的服务器实际上也可用时才有用/BLog/lAnG/.
| 归档时间: |
|
| 查看次数: |
21909 次 |
| 最近记录: |