【问题标题】:HA Proxy URL Rewrite/RedirectHAProxy URL 重写/重定向
【发布时间】:2015-10-27 08:17:47
【问题描述】:

我正在尝试重写一个 URL,但到目前为止还没有成功。

来自外部的 URL 访问 - https://example.domain.com/health(给出 404) 后端 URL 需要重定向 - http://example.domain.com/appname/health

我有多个域配置了这个 HAproxy。比如例子1、例子2 Haproxy 版本是 1.4.22 我尝试了一些解决方法 reqrep(我猜是正则表达式),重定向(无法匹配 404)到目前为止没有一个成功。如果适用,有人可以建议我使用正则表达式的解决方法。

【问题讨论】:

  • 请包含配置。
  • 正如@TanHongTat 所说,请提供您尝试过的内容(配置/等)

标签: regex redirect url-rewriting url-routing haproxy


【解决方案1】:

如果您提供配置会更容易,但是,您似乎只想将特定 URL 重定向到另一个 URL。

您可以使用“redirect”关键字来实现此目的。

有多种方法可以实现你想要的,使用不同的“重定向”关键字组合,所以这里有一个解决方案:

frontend http
   acl is_health url_reg ^/health

   redirect prefix http://www.example.com/appname code 301 if is_health

还有一个:

frontend http
   acl is_health url /health

   redirect location http://www.example.com/appname/health code 301 if is_health

【讨论】:

    猜你喜欢
    • 2012-12-10
    • 2018-08-25
    • 1970-01-01
    • 2016-11-04
    • 2017-11-06
    • 2015-03-29
    • 2015-04-16
    • 2018-07-13
    • 2012-01-02
    相关资源
    最近更新 更多