lambad
lambad

Reputation: 1066

Problem on distributing traffic from public load balancer to nginx

I am trying to distribute requests that comes to load-balancer to azure scale set instances.

I created a scale set using a linux vm image. In image, Nginx is already installed in the vm. Nginx config is shown below:

server {
    listen 80 default_server;

    server_name _;

    return 301 https://$host$request_uri;
}

server {

    listen 443;
    listen [::]:443;
    server_name 127.0.0.1 127.0.0.1 *.cloudapp.azure.com;
    ssl_certificate /usr/local/etc/ssl/certs/certi/domain-crt.txt;
    ssl_certificate_key /usr/local/etc/ssl/certs/certi/domain-key.txt;
    ssl on;
    ssl_session_cache builtin:1000 shared:SSL:10m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
    ssl_prefer_server_ciphers on;
    access_log /var/log/nginx/access.log;
    location / {
        proxy_set_header X-Real-IP $remote_addr; 
        proxy_set_header X-Forwarded-Host $host; 
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
        proxy_pass https://127.0.0.1:9000; 
        proxy_redirect http:// https://;
    }


}

Another application(XYZ) is running in port 9000. So, Nginx is routing the request to port 9000. The application(XYZ) then consumes request and returns a response.

Now, I created a scale set with public load balancer. The load balancer rule is to listen to port 80 and send to backend port 80.

To check the health of instances, I am sending a tcpProbe(PORT 80, Interval 5, Unhealthy threshold 4).

There is a public IP address associated with loadbalancer.

However, even after hitting public ip address (or DNS name) in browser, I cannot see the application running in port 9000.

I am new to Azure and Nginx and having a tough time implementing it. All I want to do is run multiple instances of my vm image using scale set and loadbalancer.

The resources that were created while creating scale set are pip, vnet, scaleset, lb,nsg.

How do I distribute traffic from load-balancer to nginx? Any hint, suggestion on how I can debug it.

Upvotes: 0

Views: 462

Answers (1)

msrini-MSIT
msrini-MSIT

Reputation: 1502

The traffic flow is as follows:

Client on port 80 --> LB(80) --> Nginx (80) redirect to port 443 with location header Client on port443 --> LB(443) --> Nginx (443) another redirection to port 9000 (Not sure if it is a internal redirection)

So all you need to do is to create a LB rule on port 443 and port 9000 if it is redirection to the client so the flow remains intact.

Upvotes: 1

Related Questions