http请求haproxy切字符串

我对haproxy中的http请求有疑问。我有以下问题。

我有一个可变的网址,例如

http://mywebsite.com/job/1/hello-world/display/redirect

http://mywebsite.com/

之间的所有内容
/display/redirect

可以是可变的。现在,我希望将到达。..../display/redirect的所有内容都切除掉,以便在没有/ display / redirect的情况下转到http://mywebsite.com/job/1/hello-world,有一种方法可以定义该名称?我可以定义固定的url,但是对于可变的url来说,那到底是什么?

我一直在想类似的东西:

http-request redirect code 301 location http://mywebsite.com/ [..] if {path_beg [..]/display/redirect}
purezheng 回答:http请求haproxy切字符串

您使用模式询问了路径结束,因此您将不使用path_beg(路径以开头)-您将使用path_end(路径以结束)进行匹配。

然后使用path提取和regsub()转换器重写删除了模式的路径。使用regsub()需要HAProxy 1.6或更高版本。

http-request redirect code 301 location %[path,regsub(/display/redirect$,)] if { path_end /display/redirect }
本文链接:https://www.f2er.com/3167549.html

大家都在问