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

How to make HAProxy path use backend (including links/scripts)?

Cache/Proxy
haproxy
2
4
1.5k
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.
  • J
    jonathan.young
    last edited by Mar 1, 2023, 2:08 PM

    Hi, I have setup HAProxy so that https://abc.xyz.com/test points to backend http://def.xyz.com.

    acl                     small   var(txn.txnpath) -m beg -i /test
    http-request set-path /  if  small
    

    At the root level this works but links/images/scripts fail. Do I need to set something up on the backend to add '/test' into the links? If so, how do I do it?

    Many Thanks

    V 1 Reply Last reply Mar 1, 2023, 4:54 PM Reply Quote 0
    • V
      viragomann @jonathan.young
      last edited by Mar 1, 2023, 4:54 PM

      @jonathan-young said in How to make HAProxy path use backend (including links/scripts)?:

      At the root level this works but links/images/scripts fail. Do I need to set something up on the backend to add '/test' into the links?

      What do the requests at the backend look like? If the /test is missed you have to configure HAproxy to add it in the backend settings.

      J 1 Reply Last reply Mar 1, 2023, 9:34 PM Reply Quote 0
      • J
        jonathan.young @viragomann
        last edited by Mar 1, 2023, 9:34 PM

        @viragomann Thanks for replying. The logs show:

        Mar 1 21:21:47 pfsense haproxy[75602]: 10.1.1.50:49456 [01/Mar/2023:21:21:47.545] test~ test/<NOSRV> -1/-1/-1/-1/0 503 565 - - SC-- 4/4/0/0/0 0/0 "GET /50021701/images/image1_hp.gif HTTP/1.1"
        

        which is a blank icon. So I think I need something on the backend that will change the GET to:

        "GET /test/50021701/images/image1_hp.gif HTTP/1.1"
        

        but I am at a bit of loss how to write the script or where to put it exactly.

        Just to be clear. Backend website def.xyz.com/index.html contains an image at /50021701/images/image1_hp.gif which I want to be displayed (along with everything else in the page) when I navigate to https://abc.xyz.com/test

        Thanks for the help.

        V 1 Reply Last reply Mar 1, 2023, 10:09 PM Reply Quote 0
        • V
          viragomann @jonathan.young
          last edited by Mar 1, 2023, 10:09 PM

          @jonathan-young
          You can do something like this to insert the /test directory:

          In the backend add an ACL:
          name: notest
          path starts with
          "Not" checked
          value: /test/

          action:
          http-request set-path
          fmt: /test/%[path]
          acl: notest

          1 Reply Last reply Reply Quote 0
          • G gurpal2000 referenced this topic on Apr 30, 2024, 7:44 AM
          2 out of 4
          • First post
            2/4
            Last post
          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.