HAProxy: Add Folder Path To Backend IP Address?
-
Hey All,
Is there anyway in HAProxy to have the frontend point to a backend that includes a folder at the end of IP address ?
For example, I would love to have "https://login.domain.com" point to "http://192.168.100.10/login". I'm not looking for a redirect to this address. I would love to navigate to "https://login.domain.com" have that address resolve to my app's login page hosted at "http://192.168.100.10/login".
Here is my front and backend config, but I'm just not sure how to direct my front end to a backend located at "http://192.168.100.10/login". The backend address field only takes an IP address with no folder.
Anyone have any suggestions?
-
@uplink
You can do this with an "http-request set-path" action.You can use this in the frontend or in the backend, depending on what you exactly want to achieve. So you can redirect request to "*domain.com" to a certain backend with "host ends" in the frontend and set the "/login" path in the backend.
-
Hey @viragomann ,
Thanks for the suggestion! I was able to get a little closer using your suggestions. However, I still ran into some issues. I didn't want to get too specific with what I'm trying to do in my initial post, but I'm trying to proxy a sub domain to my self hosted Synology PhotoStation app which requires a URL like this: "sub.domain.com/photo/".
I tried using your method by setting the path to "/photo/" on the backend, but it only partially renders the page. Not sure what else I could be missing (see 1st screenshot with green title).
I also tried redirecting the frontend to "sub.domain.com/photo/" to see if that would even work, but I got a "too many redirects" error (see 2nd screenshot with blue title).
At this point I would love to get either method working, so or anyone else has any suggestions, I'm all ears :)
-
@uplink
Load the page from inside your network with <IP>/photo and check if the paths are even as flat.I suspect, that there are subfolders. In this case you would need to insert "photo/" into the path instead of replacing the whole.
-
Hey @viragomann
I'll do my best to interrupt your request. I have a screenshot below that maybe shows was your asking for?
If I were to insert "photo/" into the path, any ideas how that might be done? Admittedly, I am getting in over my head. I've only been able to use HAProxy for really simple stuff like subdomains pointed to internal ip + port proxies.
Any help would be much appreciated :)
-
@uplink
So as you can see, there are some subfolders in the path. So need to insert "/photo" just at the beginning of the path.You can do this by appending the path variable. Just replace the value with "/photo/%[path]".
-