• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
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 11.0k 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 Offline
    TheNetStriker
    last edited by Nov 26, 2016, 1:01 PM

    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 Offline
      PiBa
      last edited by Nov 26, 2016, 1:42 PM

      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 Offline
        TheNetStriker
        last edited by Nov 26, 2016, 3:44 PM Nov 26, 2016, 2:20 PM

        @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
        3 out of 3
        • First post
          3/3
          Last post
        Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
          This community forum collects and processes your personal information.
          consent.not_received