How can we help you today?

How To Configure Your Shop to Only Use HTTPS

Created by: Sophie van Vrijberghe de Coningh

Modified on: Wed, 10 Jun, 2020 at 10:29 AM


Are you a non-Dutch customer and did you order your Hypernode via Hypernode.com? Please understand you can only test HTTPS by using Let’s Encrypt.

On Hypernode we recommend serving your site only over HTTPS traffic. This is safer and is better for search index optimization.

Most of the available browsers only support HTTP/2 when your pages are served over SSL so to use this faster and newer HTTP technology, order an SSL certificate and make sure your site is only served over HTTPS.

You can find more in-depth information in this article about SSL on Hypernode.


TABLE OF CONTENTS

Dutch Customers Only: Use Regular Certificates

If you use regular certificates, link them to your Hypernode through your Service Panel first.

This will configure the certificates and the configuration for it on your Hypernode.

Order Let’s Encrypt Certificates

To order Let’s Encrypt certificates for all storefronts, use the following command:

## Create an entry for each storefront
for DOMAIN in $( n98-magerun sys:store:config:base-url:list --format=csv | sed 1d  | cut -d , -f 3 | perl -pe "s/https?://(www.)?//" | tr -d "/" | sort -u ) ; do
    echo -e "$DOMAIN www.${DOMAIN}" >> ~/.dehydrated/domains.txt
done
 
## Order the certificates
dehydrated -c --create-dirs

Don’t forget to add the cron to renew your certificates to the crontab if you are using Let’s Encrypt!

Changing Your Base URLs

If your SSL certificates are linked to your Hypernode, or you ordered Let’s Encrypt certificates, we can change the base URLs to use only HTTPS. To make this easier, we created a little Python script that changes all your base URLs to HTTPS:

## Download the script
wget -O change_baseurls.py https://gist.githubusercontent.com/hn-support/0c76ebb5615a5be789997db2ae40bcdd/raw/
 
## Execute to change the base URLs to HTTPS
python change_baseurls.py

Routing All Traffic Over SSL Using Nginx

If you configure your Magento shop to only use HTTPS, all HTTP traffic will be redirected to HTTPS.

If this is done by Magento, the database and PHP are used for making this redirect, which is expensive in resources.

This is why we must configure this in Nginx, so the redirect does not use unnecessary resources.

Run the following command to add the configuration to Nginx that routes all traffic over HTTPS:

echo 'if ($scheme = http) { return 301 https://$host$request_uri; }' >> /data/web/nginx/public.ssl_redirect

Check Settings of Third Party Solutions

After configuring your shop to only use HTTPS, please do not forget to check HTTP(S) settings of third party solutions to avoid problems, e.g.:

  • Payment providers like Adyen.
  • Stock providers like Picqer.
  • Google Analytics and Google Search Console.
S
Sophie is the author of this solution article.

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.