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

    HAProxy: How to rewrite url?

    Scheduled Pinned Locked Moved pfSense Packages
    3 Posts 2 Posters 10.9k 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
      TheNetStriker
      last edited by

      I would like to rewrite an URL on a specific HAProxy backend like this:

      http://firewall/MyPath => http://backend:8080/

      So HAProxy should simply remove the MyPath from the url when sending the request to the backend.

      My guess is that this should be possible in the "Access Control lists" section, below the "Path starts with" section. There is a + button, but nothing happens when I click on that button.
      Is this a bug or am I doing something wrong?

      1 Reply Last reply Reply Quote 0
      • P
        PiBa
        last edited by

        Look under the 'actions' to configure 'what' to do if a acl is matched. There are only a very few acl's that have extra options under the + button.

        1 Reply Last reply Reply Quote 0
        • T
          TheNetStriker
          last edited by

          @PiBa:

          Look under the 'actions' to configure 'what' to do if a acl is matched. There are only a very few acl's that have extra options under the + button.

          Thanks for the hint. I didn't found any action for url rewrite, so I guess I have to write a custom action. But I didn't find any working custom action to to this. I think I would have to use a "http-request set-path" action, but I didn't find any working examples for my rewrite.

          Could you please provide an example for a custom action that simply rewrites the url path from /MyPath to /?

          Edit: I found a working action. I've added this to the backend:
          reqrep ^([^\ ])\ /MyPath/(.) \1\ /\2

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.