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

> How to host a website on a VPS: install Nginx, publish the site, point your domain at it and add a free Let’s Encrypt certificate that renews itself.

Source: https://lowcostserv.com/guides/host-a-website-with-nginx · Publisher: LowCostServ (lowcostserv.com) · Prices in US dollars, as published on November 26, 2026.

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

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:

| Type | Name | Value |
| --- | --- | --- |
| A | `@` | `203.0.113.10` |
| A | `www` | `203.0.113.10` |

Do this first: the certificate step needs the domain to resolve. Details are in [Point a domain name to your server](https://lowcostserv.com/guides/point-a-domain-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

- [nginx.org: Beginner’s Guide](https://nginx.org/en/docs/beginners_guide.html)
- [Ubuntu Server documentation: How to configure nginx](https://ubuntu.com/server/docs/how-to/web-services/configure-nginx/)
- [Certbot (EFF): User Guide](https://eff-certbot.readthedocs.io/en/stable/using.html)
- [Let’s Encrypt: Challenge Types](https://letsencrypt.org/docs/challenge-types/)

**Put it into practice**

- [**Cloud VPS**: Cloud VPS from $3.99/mo with an unmetered 1 Gbps port.](https://lowcostserv.com/vps)
- [**Domain names**: Register with crypto, WHOIS privacy included.](https://lowcostserv.com/domains)

**Keep reading**

- [**How to secure a new Linux server in 15 minutes**: Security · 4 min read](https://lowcostserv.com/guides/secure-a-new-linux-server)
- [**How to set up your own WireGuard VPN on a VPS**: Security · 3 min read](https://lowcostserv.com/guides/set-up-wireguard-vpn)
- [**How to pay for hosting with Bitcoin**: Crypto and payments · 4 min read](https://lowcostserv.com/guides/pay-for-hosting-with-bitcoin)

## Read next Two guides to follow this one.

[All getting started guides](https://lowcostserv.com/guides/topic/start)

- [VPS vs dedicated server: how to choose](https://lowcostserv.com/guides/vps-or-dedicated-server): Shared hardware against a whole machine: performance, price, noisy neighbors, and the point where moving up pays off. (Getting started, 3 min read, Nov 12, 2026)
- [How to connect to a Windows RDP server](https://lowcostserv.com/guides/connect-to-windows-rdp): Open a remote desktop session from Windows, macOS, Linux, iPhone or Android, and fix the usual connection errors. (Getting started, 3 min read, Nov 12, 2026)

## 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 KYC**: No email, no ID
- **No DMCA**: Notices not acted on
- **Crypto friendly**: BTC, ETH, XMR, USDT, SOL
- **Unmetered**: On every plan

---

LowCostServ rents cloud VPS, dedicated servers, GPU servers and Windows RDP servers and registers domain names, with no identity check and payment in crypto. Every plan and price: https://lowcostserv.com/pricing.md · The company in facts: https://lowcostserv.com/about.md · Index of the site for language models: https://lowcostserv.com/llms.txt
