0
votes

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.

1
Did you have a Load balancing rule for port 9000? When you access LB on port 80, it forwards the traffic to port 80 in the backend pool. How can you expect a response from an application which is running on port 9000?msrini-MSIT
I have nginx installed in scale set instances (vm image). Nginx listens to port 80 and redirects to https (443). If request comes to port 443 directly, nginx then sends the request to port 9000. So, forwarding request to 9000 is done by nginx. I am trying to send request from load balancer port 80 to nginx port 80. Do not know if this is correct, so need help.lambad
Create a rule in LB on port 443 as well as port 9000 and try againmsrini-MSIT

1 Answers

1
votes

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.