【问题标题】:Haproxy redirection but keeping the URL same?Haproxy 重定向但保持 URL 不变?
【发布时间】:2021-10-13 00:29:39
【问题描述】:

我在https://example.com/assets/content/foo.xml 下有一个xml 文件,但我希望它以https://example.com/foo.xml 的身份访问它。所以结果将是,浏览器 URL 应该是 = https://example.com/foo.xml 但我将从 https://example.com/assets/content/foo.xml 位置获取文件上下文。如何在 haproxy 中设置?

我尝试了许多解决方案,但都没有奏效。这是我尝试过的,这是完全错误的。

acl SEO_XML  path_beg -i /foo.xml
http-request set-header         X-Location-Path %[capture.req.uri] if SEO_XML
http-request replace-header     X-Location-Path /foo.xml /assets/content/foo.xml if SEO_XML
http-request redirect location  %[hdr(X-Location-Path)] if SEO_XML
use_backend shiba_dev_https            if SEO_XML

我还尝试了以下其他解决方案:

reqrep ^([^\ :]*)\ /foo.xml/(.*)    \1\ /assets/content/foo.xml/\2
  http-request set-header Host example.com
  http-request replace-path /foo.xml(.*) /assets/content/foo.xml\1

这些都不起作用,因为我不知道该怎么做。有什么想法吗?

Haproxy 版本 = 1.8

【问题讨论】:

    标签: haproxy haproxy-ingress


    【解决方案1】:

    试试这个:

    reqirep  ^([^\ :]*)\ /foo.xml\ (.*) \1\ /assets/content/foo.xml\ \2 if { path_beg /foo.xml }
    

    【讨论】:

      猜你喜欢
      • 2015-09-05
      • 2018-08-25
      • 1970-01-01
      • 1970-01-01
      • 2015-10-27
      • 1970-01-01
      • 2012-12-10
      • 2020-02-12
      • 1970-01-01
      相关资源
      最近更新 更多