HAProxy: accessing multiple sites by typing a "folder" name?

Started by jonf, February 02, 2023, 11:13:36 AM

Previous topic - Next topic
Hi,

I currently have a DDNS hostname which points to my IP address and this is currently setup to redirect to one of my Docker containers on my server in the HAProxy settings. I have a second container which I also want to access remotely and I was wondering if I can do this in such a way that I could type a "folder" name after the hostname that would correspond to the container I want to access.

For instance, if I have Docker containers named 'first' and 'second', I would like to be able to type the following in the web browser to access each one respectively:

https://[hostname]/first
https://[hostname]/second

Is this possible in HAProxy?

It probably is, but more often than not, this has the problem that internal redirections of sites behind that kind of reverse proxy assume absolute URLs, such that they redirect you to something like /admin/logout which would not work if the site is under /first.

However, if you own a DNS domain, you can also CNAME *.domain.tld to your DDNS domain. In that case, you can map via hostnames and define any hostname on your OpnSense haproxy via a map file.

This would even work without a separate domain, because often, you get *.yourhostname.domain.tld as an automatic alias to yourhostname.domain.tld. I think Cloudflare offers this...

Intel N100, 4 x I226-V, 16 GByte, 256 GByte NVME, ZTE F6005

1100 down / 800 up, Bufferbloat A+