【发布时间】: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
【问题讨论】: