【问题标题】:http request haproxy cut stringhttp请求haproxy剪切字符串
【发布时间】:2019-11-04 10:27:05
【问题描述】:

我有一个关于 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}

【问题讨论】:

    标签: apache http if-statement xmlhttprequest haproxy


    【解决方案1】:

    您询问了带有模式的路径结尾,因此您不会使用path_beg(路径以开头)-您将使用path_end(路径以结尾)进行匹配.

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

    http-request redirect code 301 location %[path,regsub(/display/redirect$,)] if { path_end /display/redirect }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-21
      相关资源
      最近更新 更多