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.
- 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 emailyourdomain.com→ Your actual domain
- 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.conf2. 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
.envfile 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: