I've been scouring the depths of the internet trying to get HAProxy to behave but im not sure it can accomplish what I want.
I tried following this: https://www.haproxy.com/blog/howto-write-apache-proxypass-rules-in-haproxy/
Here is my scenario: I've got a VM that is running app1 on port 8999. When I go to https://PUBLIC-IP-ADDRESS/app1
HAProxy should bring up root of app1 at http://backend-ip:8999/
.
The issue I'm facing is that I can get HAProxy to proxy the initial connection but all subsequent requests go to the root of the default backend server.
frontend www-https
bind *:8989 ssl crt /ssl/server.pem
log global
option httplog
reqadd X-Forwarded-Proto:\ https
rspadd Strict-Transport-Security:\ max-age=31536000;\ includeSubDomains
acl app1 path_beg -i /app1 /app1/
use_backend www-app1 if app1
default_backend www-backend
backend app1
option http-server-close
option forwardfor
reqirep [\:])\ /app1/(.) \1\ /\2
acl hdr_location res.hdr(Location) -m found
rspirep Location:\ (https?://Public-IP-ADDRESS(:[0-9]+)?)?(/.*) Location:\ /app1\3 if hdr_location
server app1 bk.IP-ADDRESS:8999 check
Going to /app1/
now works but all links point to /
. So clicking anywhere brings me back to https://PUBLIC-IP-ADDRESS
.
Any help is greatly appreciated.