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

    HAProxy config for domain forwarding

    Scheduled Pinned Locked Moved Cache/Proxy
    3 Posts 2 Posters 464 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.
    • G
      gcjh01
      last edited by

      Hi,
      I need to forward traffic to different backend servers based on the TLD/Path. I've installed HAProxy and used one of the examples as a guide, but it's not working as expected. The two domains are:
      wss://blah.example.com:7000/device/ws/
      https://blah.example.com:7000/api/v2/device/

      I have the backends configured in HAProxy. The issue is the frontend is sending all traffic to one backend. I've tried host starts with: with values of wss and https. Next I tried path contains: and used values ws and API. Neither worked.

      Suggestions?

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

        @gcjh01 said in HAProxy config for domain forwarding:

        wss://blah.example.com:7000/device/ws/
        https://blah.example.com:7000/api/v2/device/

        I have the backends configured in HAProxy. The issue is the frontend is sending all traffic to one backend. I've tried host starts with: with values of wss and https.

        These values are just the schemes, but not part of the hosts.
        The host is "blah.example.com" in both cases. So if you have no other hosts on public port 7000 you don't need to configure an ACL for it.

        Just add an ACL with "Path starts with:" "/device/ws" and a second with "Path starts with:" "/api/v2/device". Then add an action for each to use the desired backend.

        However, I don't know if HAproxy even works with Websockets.

        G 1 Reply Last reply Reply Quote 0
        • G
          gcjh01 @viragomann
          last edited by

          @viragomann Thanks. I tried your suggestions, yet all traffic still goes to the was://blah.example.com/...
          When I enter https://blah.example.com:7000/api/v2/device in a browser the response come from the websocket (was://)

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