Magento 2 If you would like to SSL

If you would like to SSL

– Generate SSL Letsencrypt

We will secure our Magento installation using SSL from Letsencrypt. Install the Letsencrypt using the apt command below.

sudo apt install letsencrypt -y

After the installation is complete, stop the nginx service.

systemctl stop nginx

Now generate the SSL certificates for the domain name using certbot command as below.

certbot certonly --standalone -d

Type your email address, accept the Letsencrypt TOS, then type ‘N’ for email sharing.

When it’s complete, you will get the result as below.

The Letsencrypt SSL certificate files have been generated to the ’/etc/letsencrypt/live’ directory.

FOR SSL  Configure Nginx Virtual Host file

upstream fastcgi_backend {
        server  unix:/run/php/php7.1-fpm.sock;

server {
    listen 80;
    listen [::]:80;
    return 301 https://$server_name$request_uri;

server {

        listen 443 ssl;

        ssl on;
        ssl_certificate /etc/letsencrypt/live/;
        ssl_certificate_key /etc/letsencrypt/live/;

        set $MAGE_ROOT /var/www/magento2;
        set $MAGE_MODE developer;
        include /var/www/magento2/nginx.conf.sample;
Scroll to Top