I already asked this question at serverfault here (http://serverfault.com/questions/754236/haproxy-and-fhem-how-to-path-redirect-correctly), actually. Of course I will update both threads regularly.
I want to have the site www.url.at/ha redirected in the backend to 127.0.0.1:8083. The url should remain “www.url.at/ha” (or “www.url.at/ha/images/”… or “www.url.at/ha/?test=12”).
This works on most of my webinterfaces, but somehow or other there are problems with fhem. fhem uses a 302 redirect to /fhem if there is any request not targeting /fhem or /fhem/xxx/…
So I implemented a reqrep, which rewrites (1)/ha/(2) to (1)/fhem(2), resulting in getting shown the index file correctly (127.0.0.1:8083/fhem).
But: the images, js, css, etc. are trying to get www.url.at/fhem/images/…
So the subsequent requests generated by (the source-code)? of the website links to the (wrong) main_server backend.
How can I achieve a correct redirection / reqrep for this specific case? I hope I have expressed myself in an understandable way…
My configuration:
frontend https-frontend
bind *:443 ssl crt cert.pem
default_backend main_server
# Add missing slash if required...
acl ms_ha path_reg ^\/ha[^\/]*$
redirect code 301 prefix / drop-query append-slash if ms_ha
acl is_ha path_beg /ha/
use_backend be_ha if is_ha
backend main_server
mode http
server raspi-test 192.168.10.95:80
backend be_ha
mode http
reqrep ^([^\ ]*\ )/ha/(.*) \1fhem\2
server ha-server 127.0.0.1:8083