A reverse proxy is the one service that listens on ports 80 and 443 to the outside and passes requests to the right application based on the hostname. This way a website, Nextcloud, a Node.js service and a game server panel run on one root server under their own subdomains, each with its own certificate. With Nginx that is one configuration file per service.
The principle
Every application only listens locally on its own port, such as 127.0.0.1:3000. Nginx accepts all requests from outside, checks the hostname and forwards them to the matching port. Advantages: one central place for certificates, access rules and logs, and no service has to speak HTTPS itself.
Installing Nginx and creating a service
- apt install nginx, then open ports 80 and 443 in ufw.
- One file per service in /etc/nginx/sites-available/, e.g. app.your-domain.de.
- In it a server block with server_name app.your-domain.de and location / { proxy_pass http://127.0.0.1:3000; }
- Forward the headers Host, X-Real-IP and X-Forwarded-Proto, otherwise the application only sees the proxy.
- Symlink to sites-enabled, nginx -t to test, systemctl reload nginx.
HTTPS with Let's Encrypt
Certbot obtains free certificates and renews them automatically: apt install certbot python3-certbot-nginx, then certbot --nginx -d app.your-domain.de. Certbot enters the certificate paths in the server block and sets up the redirect from HTTP to HTTPS. Requirement: the subdomain points to the server via a DNS A record.
WebSockets, uploads and timeouts
| Application | Setting | Why |
|---|---|---|
| Chat, panels, live data | proxy_set_header Upgrade and Connection "upgrade" | WebSockets need the connection upgrade |
| Nextcloud, uploads | client_max_body_size 2G | Default is 1 MB |
| Long computations | proxy_read_timeout 300 | Default timeout is 60 seconds |
| Docker containers | Publish ports on 127.0.0.1 only | Otherwise the container bypasses proxy and firewall |
Security at the proxy
- Restrict admin interfaces to your IP via allow/deny or protect them with basic auth.
- Rate limiting with limit_req against brute force on login pages.
- Hide the server version: server_tokens off.
- Keep access logs, Fail2ban reads them.
Root server for several services
Dedicated cores and RAM, NVMe, your own kernel control. Ideal for proxy, website, Nextcloud and bots on one machine.