# Multiple websites and applications on one VPS: Nginx as a reverse proxy

> How to run several applications on one VPS, each on its own domain with a Let's Encrypt certificate. Nginx as a reverse proxy on a Hukot.net VPS.

Source: https://www.hukot.net/community/en/tutorials/multiple-websites-and-applications-on-one-vps-nginx-as-a-reverse-proxy
Updated: 2026-11-25

A reverse proxy is a web server that receives all requests on ports 80 and 443 and passes each one to the right application based on the domain. This lets you run several websites and applications on one VPS, each on its own domain with an HTTPS certificate, while the applications themselves stay hidden inside the server.

For maximum stability, we recommend installing it on a [Hukot.net VPS](https://www.hukot.net/en/linux-vps/): your server is ready within 60 seconds of ordering and your data stays in a data centre in the Czech Republic.

## Prerequisites

- A VPS with Ubuntu 22.04 / 24.04 / 26.04 LTS or Debian 12 / 13 and SSH access with `sudo` rights.
- For each application, a domain or subdomain whose `A` record (and `AAAA` if you use IPv6) points to the server's IP address. You can edit the records by following [How to edit DNS](tutorial:238).
- Applications that listen only on `127.0.0.1`, each on its own port. For applications in Docker, publish the port as `127.0.0.1:<port>:<port>`.

::: tutorial 286 Before you start
Most applications today run in Docker. Install it by following this tutorial and publish application ports only on 127.0.0.1.
:::

Every additional application on the server needs memory. When you run out, you can [switch to a higher tariff](tutorial:272) right in the administration and pay only the difference.

## Installing Nginx and Certbot

1. Install Nginx and Certbot, which issues and renews Let's Encrypt certificates:

   ```bash
   sudo apt update
   sudo apt install -y nginx certbot python3-certbot-nginx
   ```

2. If you use the UFW firewall, allow HTTP and HTTPS:

   ```bash
   sudo ufw allow 'Nginx Full'
   ```

   To set up the firewall, see [Setting up a firewall with UFW](tutorial:96).

3. Enable WebSocket support. Most modern applications need it (n8n, Open WebUI, Uptime Kuma). Create the file `/etc/nginx/conf.d/websocket.conf`:

   ```bash
   sudo nano /etc/nginx/conf.d/websocket.conf
   ```

   ```nginx
   map $http_upgrade $connection_upgrade {
       default upgrade;
       ''      close;
   }
   ```

## An application on its own domain

1. Create a separate configuration file for each application, named after its domain:

   ```bash
   sudo nano /etc/nginx/sites-available/<domain>
   ```

2. Paste into it:

   ```nginx
   server {
       listen 80;
       listen [::]:80;
       server_name <domain>;

       client_max_body_size 50M;

       location / {
           proxy_pass http://127.0.0.1:<port>;
           proxy_http_version 1.1;
           proxy_set_header Upgrade $http_upgrade;
           proxy_set_header Connection $connection_upgrade;
           proxy_set_header Host $host;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_set_header X-Forwarded-Host $host;
           proxy_set_header X-Forwarded-Proto $scheme;
           proxy_read_timeout 300s;
       }
   }
   ```

   Replace `<domain>` with the application's domain, for example `app.example.com`, and `<port>` with the port the application listens on. `client_max_body_size` sets the largest file that can be uploaded to the application.

3. Enable the site and check the configuration:

   ```bash
   sudo ln -s /etc/nginx/sites-available/<domain> /etc/nginx/sites-enabled/
   sudo nginx -t
   sudo systemctl reload nginx
   ```

   `nginx -t` should end with `syntax is ok` and `test is successful`. If it doesn't, fix the file according to the error message before reloading Nginx.

Add another application the same way: a new file with a different domain and a different port.

## HTTPS certificate

Issue a Let's Encrypt certificate for each domain:

```bash
sudo certbot --nginx -d <domain>
```

On the first run, Certbot asks for an e-mail address for expiry notices and for your agreement to the terms. It then adds HTTPS and a redirect from HTTP to the configuration itself.

The certificate is valid for 90 days and renews automatically. Check that the renewal timer is running and that a renewal succeeds:

```bash
systemctl list-timers | grep certbot
sudo certbot renew --dry-run
```

## Verification

1. Check that the application responds over HTTPS. The first line of the output should show status `200` or a redirect to a login page (`302`):

   ```bash
   curl -I https://<domain>
   ```

2. Check that the application itself listens only locally and that only ports `80` and `443` are open to the outside:

   ```bash
   sudo ss -tlnp
   ```

   The application's port should be listed as `127.0.0.1:<port>`.

## Common errors

| Error | Cause and fix |
|---|---|
| `502 Bad Gateway` | The application isn't running or listens on a different port. Check `docker compose ps` and the port in `proxy_pass`. |
| `413 Request Entity Too Large` | The uploaded file is larger than `client_max_body_size`. Increase the value and reload Nginx. |
| `504 Gateway Timeout` | The application takes longer than `proxy_read_timeout` to respond. Increase the value. |
| Redirect loop | The application doesn't know it runs behind HTTPS. Check the `X-Forwarded-Proto` header and the public URL setting in the application. |

Nginx error messages are in the log:

```bash
sudo tail -f /var/log/nginx/error.log
```

## Why choose our VPS?

Unlike public clouds, we guarantee that your data stays in the Czech Republic, with top-class connectivity. On one Hukot.net VPS you can run your website, internal tools and automations, each with its own domain and certificate.

::: cta
## Want all your applications on one server?

Order a VPS from Hukot.net and get your first application running on its own domain today.

[Choose a VPS configuration](https://www.hukot.net/en/linux-vps/)
:::
