Get started

Getting started

How to host a website on a VPS with Nginx and free HTTPS

Install Nginx, publish a site, point your domain at it and add a free Let’s Encrypt certificate that renews itself.

By LowCostServ · Updated November 12, 2026 · 3 min read

Val plants a signpost carrying a browser window with a padlock, beside a server rack.

This guide takes a fresh Ubuntu or Debian VPS to a website served over HTTPS, with a certificate that renews itself. It assumes you can log in over SSH with a sudo user and that you own a domain name. The examples use example.com and the address 203.0.113.10.

1. Point the domain at the server

In your DNS settings, create two records:

TypeNameValue
A@203.0.113.10
Awww203.0.113.10

Do this first: the certificate step needs the domain to resolve. Details are in Point a domain name to your server.

2. Install Nginx

sudo apt update
sudo apt install -y nginx

If a firewall is active, open the web ports:

sudo ufw allow 80,443/tcp

Visit http://203.0.113.10 in a browser. The “Welcome to nginx” page means the server is answering.

3. Create the site

Make a directory for the files and put a first page in it:

sudo mkdir -p /var/www/example.com
echo '<h1>It works.</h1>' | sudo tee /var/www/example.com/index.html

Describe the site to Nginx in /etc/nginx/sites-available/example.com:

server {
    listen 80;
    listen [::]:80;
    server_name example.com www.example.com;

    root /var/www/example.com;
    index index.html;

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

Enable it, test the configuration and reload:

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

http://example.com should now show your page.

4. Add HTTPS

Certbot requests a free certificate from Let’s Encrypt and edits the Nginx configuration for you:

sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d example.com -d www.example.com

Accept the terms. Certbot then asks for an email address: recent versions let you leave it empty, older ones (the one Ubuntu 24.04 installs, for example) need --register-unsafely-without-email at the end of the command to go without. Certbot adds the certificate, a redirect from HTTP to HTTPS, and a timer that renews the certificate before it expires. Check the renewal with:

sudo certbot renew --dry-run

5. Two settings worth adding

Inside the server block that listens on 443, compress text and let browsers cache static files:

    gzip on;
    gzip_types text/css application/javascript application/json image/svg+xml;

    location ~* \.(css|js|png|jpg|webp|avif|svg|woff2)$ {
        expires 30d;
        add_header Cache-Control "public";
    }

Run sudo nginx -t && sudo systemctl reload nginx after every change. nginx -t refuses a broken configuration before it can take the site down.

Serving an application instead of files

For a Node, Python or Go application listening on a local port, replace the location / block with a proxy, and remove the block for static files added in step 5: with it, Nginx would look for the application’s CSS and JavaScript on disk and answer 404.

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

Keep the application bound to 127.0.0.1 so that Nginx is the only way in.

When it does not work

  • Certbot fails with a DNS or connection error: the domain does not point to this server yet, or port 80 is closed. Check with dig +short example.com.
  • You still see the default page: the server_name does not match the address you typed, or the site was not enabled.
  • 403 Forbidden: Nginx cannot read the files. sudo chmod -R o+rX /var/www/example.com fixes the usual case.
  • What went wrong? sudo tail /var/log/nginx/error.log says so in one line.

Sources and further reading

Your own server, in a few minutes.

Cloud VPS from $3.99 a month: no email, no ID, crypto payment, root access in minutes.

  • No KYCNo email, no ID
  • No DMCANotices not acted on
  • Crypto friendlyBTC, ETH, XMR, USDT, SOL
  • UnmeteredOn every plan

Client area

One key for your servers, your payments and your balance.

  • Nothing about you. No email, no name, no phone number, no ID.
  • Pay in crypto. BTC, ETH, XMR, USDT and SOL.
  • Up to +30% on top-ups. The bonus starts at $100.
  • Yours alone. We keep a fingerprint of your key, never the key itself.
How the access key works

Your account

No email, no password, no name. One access key.

New here? Create your access key