locked
Not able to redirect HTTP to HTTPS with azure standard loadbalancer RRS feed

  • Question

  • Hello,

    I setup azure standard loadbalancer and setup VM with nginx. Then i setup SSL on VM is working perfectly if user send request with https://mydomain.com but when i am redirect http to https it is not working, I am getting not respond with redirection.

    I also try the same configuration of nginx with single VM i am able to redirect http to https and its working perfectly.

    Below is my nginx configuration

    server {
          listen 80 default_server;
            listen [::]:80 default_server;
            server_name _;
            return 301 https://$host$request_uri;
    }
    
    server {
            listen 443 ssl;
            root /var/www/html;
            server_name *.mydomain.com;
            ssl_certificate /etc/letsencrypt/live/mydomain.com/fullchain.pem;
            ssl_certificate_key /etc/letsencrypt/live/mydomain.com/privkey.pem;
            location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                #try_files $uri $uri/ =404;
                try_files $uri $uri/ /index.html?$args;
    
           }
    }
    Thanks in advance.
    Thursday, December 19, 2019 12:35 PM

Answers

  • This should be able to get working on a Load Balancer as well. Does the site come up well whenever you access it normally via HTTPS using the load balancer public endpoint?

    If you are giving off a redirect, be sure that your health probes are either TCP, or using port 443. 

    another option for HTTP / HTTPS redirection will be to use an Azure Application Gateway. This is supported natively with redirect rules. 

    Thursday, December 19, 2019 11:46 PM

All replies

  • This should be able to get working on a Load Balancer as well. Does the site come up well whenever you access it normally via HTTPS using the load balancer public endpoint?

    If you are giving off a redirect, be sure that your health probes are either TCP, or using port 443. 

    another option for HTTP / HTTPS redirection will be to use an Azure Application Gateway. This is supported natively with redirect rules. 

    Thursday, December 19, 2019 11:46 PM
  • Thanks @TravisCragg_MSFT.

    I am able to resolve the issue. 

    The problem is in health probe i setup different health probe for 80 and 443 , then i just remove the 80 health probe and in port 80 rule i set a 443 port health probe and its working.

    Thanks

    Friday, December 20, 2019 4:56 AM