Overview
The following describes how to force an Nginx site to load securely after an SSL certificate has been added.
FAQs
Does the site automatically load the secure URL?
-
After you have added an SSL certificate to your domain, DreamHost automatically redirects the URL visitors use to view your site from HTTP to HTTPS. The S ensures that your connection is encrypted (e.g., https://example.com).
There's nothing on your end you must do in order to force your site to use the secure URL. However, in some special cases, it may be necessary for you to create your own custom configuration file to force the redirect from HTTP to HTTPS.
Do I need to add custom code to load the secure URL?
-
Adding custom code is only necessary if your website requires specific code to force the redirect. If so, you will need to first disable the automatic redirect in your panel. Once disabled, you can then proceed with adding your custom redirect file.
Redirecting non-secure traffic to HTTPS
This step is only necessary if your website requires custom code to force a redirect.
To redirect all website URLs to the secure URL, you must manually create a redirects.conf file via FTP or SSH. You will then add your redirect code to this file. View the Nginx configuration file locations article for instructions on where to create the redirects.conf file.
Redirect code
The following code forces all URLs to load the HTTPS version of your site, ensuring your visitor's connections are encrypted.
if ($server_port = 80) {
rewrite ^/(.*)$ https://example.com/$1 permanent;
}