0

I have a xml file under https://example.com/assets/content/foo.xml but I want it to access it as https://example.com/foo.xml. So outcome will be, the browser URL SHOULD BE = https://example.com/foo.xml but I will get the file context from https://example.com/assets/content/foo.xml location. How to set it in haproxy ?

I tried many solutions but none of them worked. here is what I tried and this would be completely wrong.

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

I have also tried other solutions as follows :

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

None of this worked as I have no clue how to do it. Any ideas pls ?

Haproxy Version = 1.8

SAGAR BHOOSHAN
  • 309
  • 2
  • 11

1 Answers1

0

Try this:

reqirep  ^([^\ :]*)\ /foo.xml\ (.*) \1\ /assets/content/foo.xml\ \2 if { path_beg /foo.xml }
Nick Ramirez
  • 473
  • 5
  • 15