Redirect to https in nginx load balancer

If you have an nginx load balancer in you environment and want to redirect all requests to https then you can add the following configuration.

On the nginx load balancer node select config and create a new file under conf.d named redirect.conf.
Add the following configuration to the file, save it and restart nginx.

server {
       listen *:80 default_server;
       access_log /var/log/nginx/redirect.access_log main;
       error_log /var/log/nginx/redirect.error_log info;
       location / {
         rewrite ^ https://$host$request_uri? permanent;
       }
}

 This configuration requires that you have a Public IP address on your nginx load balancer. 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.