Nekode

Domain & SSL

How to install a custom domain and SSL (certbot)

Rifki ahmad fahrezi

Rifki ahmad fahrezi

Installing a domain to a server IP and installing SSL with Certbot

Make sure you have purchased a domain name, either from Hostinger or another provider. If you buy a domain from a different provider, you must add your domain to the VPS server, here's how:

  1. Go to hpanel VPS hostinger, then click DNS Manager then in the add domain form enter the domain name you bought, after that a way to change the name server to hostinger will appear, (If you buy a domain from hostinger you can just skip this step)
  2. Log back into the VPS server, then update the Nginx config and change the IP in server_name to the domain name
sudo nano /etc/nginx/sites-available/nextjs.conf

Find the server_name section then change it to `server_name your-domain.com www.your-domain.com;

  1. Restart Nginx
sudo service nginx restart

You can also check first whether the Nginx configuration file is successful or not error by running sudo nginx -t

  1. Install Certbot
sudo snap install --classic certbot
  1. Create cerbot command
sudo ln -s /snap/bin/certbot /usr/bin/certbot
  1. Install SSL certificate
udo certbot --nginx
  1. Test automatic renewal of SSL certificate with Certbot without actually renewing the certificate, one of the purposes is to check whether the domain is still valid and can be verified by let's encrypt
sudo certbot renew --dry-run

After all changes to DNS are applied (can take up to 2 days, check periodically), the Nextjs website that you deployed will be available on the domain you registered along with the SSL certificate that is already actively installed

On this page