Host a website on your VPS with Nginx and a free SSL certificate

Point your domain at your VPS, set up Nginx with a server block and get a free Let's Encrypt certificate with Certbot that renews by itself.

EliteStarHosting Team8 November 2026Updated 26 November 20264 min read
Ready to start? View the VPS Hosting plans

With Nginx you host a website on your own VPS, and Certbot gets you a free certificate from Let's Encrypt for HTTPS. This guide works on Debian and Ubuntu. Log in as your user with sudo, as in Secure your new Linux VPS. In the examples, replace yourdomain.com with your own domain.

Don't want to manage a server? Then web hosting with DirectAdmin is easier: SSL and WordPress take one click there. If you want full control, rent a VPS from €3 a month.

Point your domain at your VPS

Create two A records with the IP address of your VPS, for example 203.0.113.10: one for @ (the domain itself) and one for www. Where you do that depends on your domain:

  • With us, without web hosting: in the client area under DNS Management.
  • With us, with web hosting: in DirectAdmin under Account Manager > DNS Management. Is your main site staying on the web hosting? Then only point a subdomain at the VPS, as in Point a subdomain to another server.
  • Elsewhere: at your registrar or DNS provider.

Use the address of your VPS here. The address 87.76.153.137 from Connect your domain is only for our web hosting. Is there an AAAA record for the same name that points somewhere else? Remove it, or Let's Encrypt can't verify your domain. Test with nslookup yourdomain.com: you should see the address of your VPS.

Open ports 80 and 443

sudo ufw allow 80/tcp
sudo ufw allow 443/tcp

Keep port 80 open, also once HTTPS works: Let's Encrypt checks your domain over port 80 when the certificate is renewed. More is in Set up a firewall with UFW.

Install Nginx and add your site

sudo apt update
sudo apt install nginx
sudo mkdir -p /var/www/yourdomain.com
echo '<h1>It works</h1>' | sudo tee /var/www/yourdomain.com/index.html
sudo nano /etc/nginx/sites-available/yourdomain.com

Nginx starts by itself, also when your VPS boots. Put this server block in the file and save it:

server {
    listen 80;
    listen [::]:80;
    server_name yourdomain.com www.yourdomain.com;
    root /var/www/yourdomain.com;
    index index.html;

    location / {
        try_files $uri $uri/ =404;
    }
}

Turn the site on, test the configuration and reload Nginx:

sudo ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

http://yourdomain.com now shows It works. Your own files go into /var/www/yourdomain.com.

A certificate with Certbot

In November 2026, certbot.eff.org recommends installing Certbot as a snap. Ubuntu already has snap. On Debian, install snap first with the first line below, log out and in again, and update it with the second:

sudo apt install snapd
sudo snap install snapd

Installed Certbot with apt before? Remove it first with sudo apt remove certbot. Then install Certbot and request the certificate:

sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/local/bin/certbot
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com

Certbot asks for an email address (Enter skips it) and whether you accept the terms. It then adds HTTPS to your server block and redirects visitors from HTTP to HTTPS. Open https://yourdomain.com: you now see the padlock. Does it fail? Check the A record and port 80 first, because Let's Encrypt allows at most 5 failed attempts per name per hour.

Automatic renewal

In November 2026 a Let's Encrypt certificate is valid for 90 days, from 10 February 2027 for 64 days. You don't need to do anything for that: Certbot comes with a timer that renews in time. systemctl list-timers shows it. Test the renewal with:

sudo certbot renew --dry-run

Rather have a WordPress site without server maintenance? Our web hosting includes one-click WordPress, free SSL and weekly backups.