Forcing HTTPS on Nginx Load Balancers

A common way to issue a Let’s Encrypt cert and get things to load on Reclaim Cloud over HTTPS is to use an NGINX Load Balancer. Here's an example environment running WriteFreely:

mceclip0.png

The trick is some applications that you run won’t automatically redirect URLs with HTTP to HTTPS, so you have to manually type HTTPS in your address bar. With a quick config change in NGINX, you can have the load balancer redirect all HTTP requests to HTTPS.

We'll need to make a redirect.conf file in the /etc/nginx/conf.d folder of our nginx load balancer. To get started, click the config button for the Load Balancer, then click on the conf.d folder. Next, click the cog buttonNew File:

mceclip1.png

Name the file redirect.conf and press enter to confirm. Note that the file can technically be named anything, as long as it ends in .conf.

blobid1.gif

Next, edit the file and paste the following text in the file and save it:

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;
}
}

Finally, click the Restart Node button next to your Load Balancer node!

mceclip2.png

Was this article helpful?
0 out of 0 found this helpful

Articles in this section

See more
Reclaim Hosting Support Hours
8:00 am - 5:00 pm ET, Monday through Friday
Submit a Ticket
Get a quick and helpful response from the pros.
Need Extra Support?
No problem, we're here to help! Talk to us about Professional Services or custom Service Level Agreements.