Application gateway redirection to 2 backend pools

jitendra 1 Reputation point
2021-05-05T09:38:58.613+00:00

Dear Community,

    I have a setup wherein i require the application gateway to redirect to 2 backend pools each containing 1 VM .

I have nginx instances on each VM in the backend pool
I have configured the application gateway and it reaches the First backend pool but not the second
Let me make it more clear so that y'all understand it better .
I have both the servers configured in nginx where i've put the locations as /wa1,/wa2,/wa3 and /wa4,/wa5,/wa6 respectively .

In /one we have 3 directories where i have 3 index.html's .
So let me say for namesake that it is wa1 wa2 wa3
In /two we have 3 directories where i have 3 index.html's .
So let me say for namesake that it is wa4 wa5 wa6

Only difference between them is that

1) /one endpoint points to my First backend pool .
2) /two endpoint points to my Second backend pool .

I have configured my nginx like this :

1st Backend pool VM
server {
listen 80;
listen [::]:80;

    server_name example.com;

    root /var/www/html;
    index index.html;

    location / {
            default_type application/json;
            return 200 '{"code":"1", "message": "Connected to one"}';
    }
    location /one/wa1 {
            default_type application/json;
            return 200 '{"code":"1", "message": "Connected to one and wa1"}';
            autoindex on;
    }
    location /one/wa2 {
            default_type application/json;
            return 200 '{"code":"1", "message": "Connected to one of wa2"}';
            autoindex on;
    }
    location /one/wa3 {
            default_type application/json;
            return 200 '{"code":"1", "message": "Connected to one of wa3"}';
            autoindex on;
    }

}

2nd Backend pool VM
server {
listen 80;
listen [::]:80;

    server_name example.com;

    root /var/www/html;
    index index.html;

    location / {
            default_type application/json;
            return 200 '{"code":"1", "message": "Connected to two"}';
    }
    location /two/wa4 {
            default_type application/json;
            return 200 '{"code":"1", "message": "Connected of two of wa4"}';
            autoindex on;
    }
    location /two/wa5 {
            default_type application/json;
            return 200 '{"code":"1", "message": "Connected of two of wa5"}';
            autoindex on;
    }
    location /two/wa6 {
            default_type application/json;
            return 200 '{"code":"1", "message": "Connected of two of wa6"}';
            autoindex on;
    }

Now i have configured the URL rewrites for the server as well , and for the first back end pool it reaches it properly

Meaning in the HTTP URL rewrite tab in nginx , i configured the URL with the names like

/one/wa1 ---> applicationgwip/clientone
/one/wa2 ---> applicationgwip/clienttwo
/one/wa3 ---> applicationgwip/clientthree

/two/wa4 ---> applicationgwip/clientfour
/two/wa5 ---> applicationgwip/clientfive
/two/wa6 ---> applicationgwip/clientsix

Now in the URL when i type appgwip/clientone , appgwip/clienttwo , appgwip/clientthree
It reaches the servers perfectly fine .

But as soon as i hit

appgwip/clientfour , appgwip/clientffive , appgwip/clientsix

It points to location in my / of my first backend pool .
Meaning it hits / of the first backend pool .

This is really weird behaviour considering the fact it reaches it directly if i give

appgwip/two/wa4 .. appgwip/two/wa6

Can someone guide me about how should i be able to redirect http url's to the second backend pool ?

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,076 questions
{count} votes

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.