Redirect requests to specific path to different backend port

Oscar Bergenbrink 0 Reputation points
2025-03-05T08:51:04.7233333+00:00

Hi.

We have an application gateway and then one host in the backend pool. We have a listner on 443 and then a rule which sends that traffic over to the backendpool on a specific port. However, there's a chat in the backend application which wants to do some connections on another port when you send a request to /websocket. We have tried to make this work with: another backend setting which has the other port. And then a path-based rule with "path = /websocket*, Target name = websocket, Backend setting name = name of the other backend setting, Backend pool = our 1 and only pool".

When I have the "normal" rule as highest prio, all normal operations work but the /websocket requests are not treated differently, and when I change the path-based rule to have a higher priority I get a invalid gateway error.

To sum it up the goal is:
Rule 1 = send 443 requests to backend
Rule 2 = send /websocket to same backend but with a specified port

Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
1,216 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ganesh Patapati 6,915 Reputation points Microsoft External Staff Moderator
    2025-03-05T15:23:22.7+00:00

    Hello Oscar Bergenbrink

    Thanks for the reply!

    We did a repro on your setup,

    image (42)

    1. And, would like to inform you that separate listeners need to be created to handle port 80/443 traffic and another port (e.g., 8080 for websocket traffic).
    2. Additionally, separate routing rules must be created to map the HTTP/HTTPS traffic and another routing rule with path-based routing for websocket traffic.
    3. Please ensure that separate backend HTTP settings are configured: one for HTTP/HTTPS and another for port 8080. You can configure a single backend pool to accept both HTTP/HTTPS and websocket traffic (e.g., port 8080).

    NOTE: you cannot use two listeners with same frontend port on same application gateway Public IP

    MY LAB SETUP:

    STEP 1: Listener configuration

    User's imageSTEP 2: Backend Settings

    User's image STEP 3: Custom Probe

    User's image

    STEP 4: Routing Rules

    4.a) Default rule (80/ 443)

    Listeners

    User's image

    Backend TargetsUser's image 4.b) Path Based (Web socket Traffic)

    Listeners

    User's image User's image

    • If you want to see the test results I am posting via private messages, were you able to validate them.

    Can you please update us if the action plan provided by was helpful?

    Please accept an answer if correct. Original posters help the community find answers faster by identifying the correct answer. Here is how.

    Accepted answer


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.