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?
1 out of 1 found this helpful
Have more questions? Submit a request



Please sign in to leave a comment.