Skip to content

SSL Installation on VPS Server ​

Let’s Encrypt is one of the best and free solutions to install an SSL certificate on a VPS server.

This section explains how to generate and configure SSL for both your frontend and admin panel.

SSL Certificate Generation ​

Follow the steps below to generate your SSL certificate.

  1. Run the following command to create the SSL certificate:
bash
sudo docker-compose run --rm certbot certonly --webroot --webroot-path /var/www/certbot/ --email youremail@gmail.com --agree-tos --no-eff-email -d yourdomain.com

⚠ Replace:

  • youremail@gmail.com → Your actual email
  • yourdomain.com → Your actual domain
  1. You must generate SSL certificates for both:
  • Frontend domain (e.g. yourdomain.com)
  • Admin panel domain (e.g. admin.yourdomain.com)

So, run the command twice — once for each domain.

Configure SSL in NGINX ​

After generating the certificate, configure NGINX.

1. Edit NGINX Configuration ​

Run:

bash
nano nginx/config/default.conf

2. Create HTTPS Server Block ​

You need to create a new server block for HTTPS (port 443) for both frontend and admin panel.

Inside the HTTPS block, add the following lines:

nginx
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;

ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;

⚠ Replace yourdomain.com with your actual domain.

Make sure you configure both frontend and admin domains properly.

Redirect HTTP to HTTPS ​

To redirect all HTTP traffic to HTTPS:

Add the following line inside your HTTP (port 80) server block:

nginx
location / { return 301 https://$server_name$request_uri; }

This will automatically redirect all visitors to the secure HTTPS version of your site.

Important Notice ​

⚠ Important Do not forget to update the URLs inside your .env file to use https:// instead of http://. This was configured during the previous VPS setup steps.

Need Help? ​

If you face any difficulty during SSL installation, please visit:

https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-18-04