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

HAPROXY redirection to specific subdirectory on specific port

Scheduled Pinned Locked Moved General pfSense Questions
12 Posts 3 Posters 524 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.
  • T
    thefalcon79
    last edited by Dec 4, 2024, 6:59 PM

    hello all,

    i'm looking for help plz in configuring my following scenario on pfsens with HAProxy.
    now, i'm running my domain1 with acme ssl & using HAProxy,
    https://domain1:443 ==> http://192.168.1.13:80
    everything is fine and the domain1 is working on https.

    now, i need to run an new service on the same domain1 on port 8080 to a specific path:
    http://192.168.1.13.com:8080/subfolder1/subfolder2

    from outside, the users will request the new service on:
    https://domain1.com (on 443 of course)

    i have prepared another domain name (domain2.com) trying to run the above scenario...got blue and nothing worked with me to run the new service on another port with a specific path...!!

    can i find help here :(

    thanks in advanced.

    S 1 Reply Last reply Dec 5, 2024, 1:21 AM Reply Quote 0
    • S
      stephenw10 Netgate Administrator @thefalcon79
      last edited by Dec 5, 2024, 1:21 AM

      @thefalcon79 said in HAPROXY redirection to specific subdirectory on specific port:

      from outside, the users will request the new service on:
      https://domain1.com (on 443 of course)

      Do you mean domain2.com there?

      Does it work without the specific path?

      Steve

      T 1 Reply Last reply Dec 5, 2024, 2:39 AM Reply Quote 0
      • T
        thefalcon79 @stephenw10
        last edited by Dec 5, 2024, 2:39 AM

        @stephenw10
        yes, i just made it to try another way to access my internal path (http://192.168.1.13.com:8080/subfolder1/subfolder2) from out side far away from (https://domain1:443)

        i miss something in settings backend, i guess!

        V 1 Reply Last reply Dec 5, 2024, 1:54 PM Reply Quote 1
        • V
          viragomann @thefalcon79
          last edited by Dec 5, 2024, 1:54 PM

          @thefalcon79
          So you want to enter https://domain2.com in the browser and want HAproxy to call http://192.168.1.13:8080/subfolder1/subfolder2?

          Yes, this would be possible.
          You can set the backend to go to 192.168.1.13:8080 and let HAproxy insert the path.

          So I guess, the paths should be inserted into every request?
          E.g. https://domain2.com/file.html > http://192.168.1.13:8080/subfolder1/subfolder2/file.html

          T 1 Reply Last reply Dec 7, 2024, 10:28 PM Reply Quote 0
          • T
            thefalcon79 @viragomann
            last edited by Dec 7, 2024, 10:28 PM

            @viragomann yes exactly that's what i need.

            "and let HAproxy insert the path."
            i did tried with that, but it doesn't worked with me!

            @viragomann said in HAPROXY redirection to specific subdirectory on specific port:

            So I guess, the paths should be inserted into every request?
            E.g. https://domain2.com/file.html > http://192.168.1.13:8080/subfolder1/subfolder2/file.html

            i didn't got you in this,
            Do you mean modifying the index file?

            @viragomann said in HAPROXY redirection to specific subdirectory on specific port:

            and let HAproxy insert the path.

            V 1 Reply Last reply Dec 8, 2024, 9:37 AM Reply Quote 0
            • T
              thefalcon79
              last edited by thefalcon79 Dec 7, 2024, 10:49 PM Dec 7, 2024, 10:47 PM

              a screenshots of my BackEnd config. :

              alt text

              alt text

              1 Reply Last reply Reply Quote 0
              • V
                viragomann @thefalcon79
                last edited by Dec 8, 2024, 9:37 AM

                @thefalcon79 said in HAPROXY redirection to specific subdirectory on specific port:

                Do you mean modifying the index file?

                No I mean, that HAproxy just keeps the requests file, which is, what you want to achieve, I think.
                The request path mostly ends with a file (/subdir1/subdir2/file.ext). If you don't state a file, the webserver provides a default file, which can be index.html or default.aspx or any other. This is usually preset, but can be changed in the server settings.

                To achieve this for any file

                https://domain2.com/file.html > http://192.168.1.13:8080/subfolder1/subfolder2/file.html
                

                in the backend use the "http-request set-path" method and enter "/subfolder1/subfolder2%[path]" below.
                There is no need to configure an ACL if this should be applied to any request going to this backend.

                T 1 Reply Last reply Dec 8, 2024, 10:17 AM Reply Quote 0
                • T
                  thefalcon79 @viragomann
                  last edited by Dec 8, 2024, 10:17 AM

                  @viragomann thank you for your help, appreciate it.

                  haproxy3.jpg

                  this is what i have configured, but still not going to the path !

                  what did i missed !

                  V 1 Reply Last reply Dec 8, 2024, 10:26 AM Reply Quote 0
                  • V
                    viragomann @thefalcon79
                    last edited by Dec 8, 2024, 10:26 AM

                    @thefalcon79
                    You have to state this as action.

                    http-request set-path
                    fmt:/subfolder1/subfolder2%[path]

                    T 1 Reply Last reply Dec 8, 2024, 10:37 AM Reply Quote 0
                    • T
                      thefalcon79 @viragomann
                      last edited by Dec 8, 2024, 10:37 AM

                      @viragomann
                      i tried both, at Backend pass thru & as Action,
                      and still getting:
                      PAGE NOT FOUND
                      The page you requested cannot be found

                      or the browser just keep looping with no result!

                      which one is the correct typing:
                      http-request set-path moheclient/api/emis/getAllTasks%[path]
                      or
                      http-request set-path /moheclient/api/emis/getAllTasks/%[path]

                      the url:
                      http://192.168.1.13.com:8080/subfolder1/subfolder2
                      is working fine inside my lan.

                      V 1 Reply Last reply Dec 8, 2024, 10:51 AM Reply Quote 0
                      • V
                        viragomann @thefalcon79
                        last edited by Dec 8, 2024, 10:51 AM

                        @thefalcon79
                        The path begins with a "/". Hence if you exchange the path with something else, you have also use a slash in the first position.

                        If the browser loops, I assume, that the webserver give a path back to the client to request.
                        Note, that the suggested method insert "/subfolder1/subfolder2" at the beginning of the path. This is, what I understand, that you want.
                        But maybe you need something different.
                        You can use the browsers diagnostic function (F12) to investigate, what it request, if you are unsure, what your backend server does.

                        T 1 Reply Last reply Dec 8, 2024, 12:49 PM Reply Quote 0
                        • T
                          thefalcon79 @viragomann
                          last edited by thefalcon79 Dec 8, 2024, 12:50 PM Dec 8, 2024, 12:49 PM

                          @viragomann i do really appreciate your help 👍 😊
                          finally it worked for me.
                          my problem was in the port 8080 with TomCat apache, i just changed the port to 8081, reboot the server, and its worked.

                          by the way, it's working on both as Action & Backend pass thru just fine

                          again, thanks a lot @viragomann

                          1 Reply Last reply Reply Quote 0
                          12 out of 12
                          • First post
                            12/12
                            Last post
                          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
                            This community forum collects and processes your personal information.
                            consent.not_received