Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    HAProxy: Add Folder Path To Backend IP Address?

    Scheduled Pinned Locked Moved Cache/Proxy
    6 Posts 2 Posters 1.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • U
      uplink
      last edited by uplink

      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?

      f5abb54c-b7fe-4abb-87e1-f6317ca2e21d-image.png
      27147d1d-e790-4197-9a5a-9dc944d4788d-image.png

      V 1 Reply Last reply Reply Quote 0
      • V
        viragomann @uplink
        last edited by

        @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.

        1 Reply Last reply Reply Quote 0
        • U
          uplink
          last edited by uplink

          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 :)

          fd1481fc-8426-475b-82e6-7fda1ab88e0d-image.png

          268a8895-999f-4b86-b2f4-07cb3e1be848-image.png

          V 1 Reply Last reply Reply Quote 0
          • V
            viragomann @uplink
            last edited by viragomann

            @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.

            1 Reply Last reply Reply Quote 0
            • U
              uplink
              last edited by

              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 :)

              e7f36030-547e-492c-95af-f47eb0704d37-image.png

              V 1 Reply Last reply Reply Quote 0
              • V
                viragomann @uplink
                last edited by

                @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]".

                1 Reply Last reply Reply Quote 0
                • G gurpal2000 referenced this topic on
                • First post
                  Last post
                Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.