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

    Configure HAProxy backend to a url with a subdirectory?

    Scheduled Pinned Locked Moved Cache/Proxy
    2 Posts 2 Posters 1.5k 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.
    • D
      dutsnekcirf
      last edited by

      I've been able to get haproxy to proxy web requests to urls that work based purely on the alias running at the webroot. For example urls like the following:

      homeassistant.mydomain.com
      guacamole.mydomain.com
      pfsense.mydomain.com

      What I don't know how to do is configure a backend that'll forward to a url with a subdirectory underneath. For example:

      plex.mydomain.com/web
      octoprint.mydomain.com/3dprinter

      How do I get the proxy server to proxy a web request to those URLs? I don't want to have to remember to append the /web or /3dprinter to the end of my urls. I'd like to just go to plex.mydomain.com or octoprint.mydomain.com.

      Is this possible?

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

        @dutsnekcirf
        Basically there is no need to run a website within a subdirectory behind a reverse proxy. This makes things more complicated.

        However, HAproxy is able to insert a string at the beginning of the path. You can use "http-request set-path" to do this.

        You can set it in the frontend or backend. The preferred method depends on your setup.
        Add an action, select "http-request set-path" and enter "/web/%[path]" below. This assumes that the website has further subdirectories.

        However, with this, the additional path is inserted into all requests.If your website send URLs to call to the client, which already inlcludes the "/web/", you have to bind this action to an ACL to ensure it is not applied in this case.

        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.