One VPS can comfortably host several applications: a Node.js site, a Python API, a WordPress blog and an admin dashboard, for example. Only one program can listen on port 443, though, so you need something that receives every request and routes it to the right app. That is the job of a reverse proxy, and Nginx is the most common choice: it is fast, uses little memory and also handles HTTPS, compression, caching and upload limits for all your apps in one place.
How Routing Works
┌─ shop.example.com ─▶ 127.0.0.1:3000 (Next.js)
Internet ─▶ Nginx┼─ api.example.com ─▶ 127.0.0.1:8000 (FastAPI)
:80/:443 └─ example.com/blog ─▶ 127.0.0.1:8080 (WordPress container)
Nginx chooses a server block by matching the request's Host header against each block's server_name. Inside a block, location rules route by URL path. Each app listens only on 127.0.0.1, so nothing except Nginx can reach it directly.
Step 1: Run Each App on Its Own Local Port
Give every application a unique port and bind it to localhost. Examples:
| App | How to bind |
|---|---|
| Node.js / Next.js | PORT=3000 HOSTNAME=127.0.0.1 npm start, under PM2 or systemd |
| FastAPI / Uvicorn | uvicorn main:app --host 127.0.0.1 --port 8000 |
| Django / Gunicorn | gunicorn mysite.wsgi --bind 127.0.0.1:8001 |
| Docker container | ports: ["127.0.0.1:8080:80"] |
Check what is listening with sudo ss -tlnp. Anything bound to 0.0.0.0 or * is reachable from outside unless your firewall blocks it. Docker-published ports bypass UFW entirely.
Step 2: Point the Domains at the VPS
Create an A record for each hostname (shop.example.com, api.example.com and so on) with the VPS IP. A wildcard record (*.example.com) is handy if you add subdomains often.
Step 3: One Server Block per Domain
Put shared proxy headers in a snippet so every site behaves the same. Create /etc/nginx/snippets/proxy.conf:
proxy_http_version 1.1;
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-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_read_timeout 60s;
Then one file per site, for example /etc/nginx/sites-available/shop.example.com:
server {
listen 80;
server_name shop.example.com;
location / {
proxy_pass http://127.0.0.1:3000;
include snippets/proxy.conf;
}
}
and /etc/nginx/sites-available/api.example.com:
server {
listen 80;
server_name api.example.com;
client_max_body_size 25m;
location / {
proxy_pass http://127.0.0.1:8000;
include snippets/proxy.conf;
}
}
sudo ln -s /etc/nginx/sites-available/shop.example.com /etc/nginx/sites-enabled/
sudo ln -s /etc/nginx/sites-available/api.example.com /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
Why the headers matter: without Host, many frameworks generate wrong URLs; without X-Forwarded-For, every visitor appears to come from 127.0.0.1; without X-Forwarded-Proto, apps behind HTTPS think requests are plain HTTP and create redirect loops or insecure cookies. Each framework also needs to be told to trust these headers from 127.0.0.1 (Express app.set('trust proxy', 1), Django SECURE_PROXY_SSL_HEADER, Uvicorn --proxy-headers).
Step 4: Add a Catch-All Default Server
If a request arrives with an unknown Host header (for example, someone browsing your bare IP), Nginx serves it from the first server block it finds, which may expose an app on the wrong domain. Add an explicit default that closes the connection:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 444;
}
Remove the distribution's sites-enabled/default file so it does not conflict. For HTTPS, a catch-all needs a certificate; many people simply let the first real site act as the default for port 443.
Step 5: Path-Based Routing on One Domain
Sometimes you want several apps under one hostname. The trailing slash on proxy_pass decides whether the prefix is stripped:
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://127.0.0.1:3000; # main site
include snippets/proxy.conf;
}
# /api/users -> backend receives /users (prefix stripped)
location /api/ {
proxy_pass http://127.0.0.1:8000/;
include snippets/proxy.conf;
}
# /docs/intro -> backend receives /docs/intro (prefix kept)
location /docs/ {
proxy_pass http://127.0.0.1:4000;
include snippets/proxy.conf;
}
}
Path-based routing only works cleanly if the app knows its base path; otherwise links and assets point to / and break. Most frameworks have a setting for this (Next.js basePath, Django FORCE_SCRIPT_NAME, WordPress site URL). When in doubt, subdomains are simpler.
Step 6: WebSockets and Server-Sent Events
WebSockets need the HTTP/1.1 upgrade headers passed through. Define a map once in /etc/nginx/conf.d/websocket.conf:
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
and use it in the app's location:
location / {
proxy_pass http://127.0.0.1:3000;
include snippets/proxy.conf;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 3600s;
}
For Server-Sent Events, disable buffering on that location with proxy_buffering off; so events reach the browser immediately.
Step 7: HTTPS for Every Site
sudo ufw allow 'Nginx Full'
sudo certbot --nginx -d shop.example.com -d api.example.com -d example.com
sudo certbot renew --dry-run
Certbot edits each matching server block, adds the certificate and an HTTP-to-HTTPS redirect. You can issue one certificate covering several names (as above) or run Certbot once per site; separate certificates are easier to manage when sites belong to different clients. Full details are in our Let's Encrypt guide.
Useful Per-App Settings
| Need | Directive |
|---|---|
| Larger uploads | client_max_body_size 50m; |
| Long-running requests | proxy_read_timeout 300s; (better: move work to a background job) |
| Serve static files directly | location /static/ { alias /srv/app/static/; } |
| Rate-limit a login endpoint | limit_req_zone in http, then limit_req zone=login burst=10; |
| Compression | gzip on; gzip_types text/css application/javascript application/json; |
| Restrict an admin app | allow 198.51.100.25; deny all; inside its location |
SkyRainCloud Plans for This Workload
Nginx itself needs very little; the applications behind it set the requirement. Two or three small apps fit 2 vCores / 8 GB. Hosting many client sites or several databases on one server is where the 4–8 vCore tiers make sense.
Intel Xeon Platinum 8269CY VPS
KVM VPS on Intel Xeon Platinum 8269CY (up to 3.80 GHz Turbo) with DDR4 ECC memory, NVMe SSD, full root access and an unmetered 1 Gbps port.
| Plan | vCores | RAM | Storage | Network | Price | Good for | Buy |
|---|---|---|---|---|---|---|---|
| VPS 1 — Intel | 2 | 8 GB DDR4 ECC | 40 GB NVMe SSD | 1 Gbps, unmetered | ₹649/month | Business websites, small apps, scheduled jobs and bots | Order |
| VPS 2 — Intel | 4 | 16 GB DDR4 ECC | 80 GB NVMe SSD | 1 Gbps, unmetered | ₹1,169/month | Business software, mid-size databases, several sites on one server | Check stock |
| VPS 3 — Intel | 8 | 32 GB DDR4 ECC | 150 GB NVMe SSD | 1 Gbps, unmetered | ₹2,249/month | ERP/CRM stacks, heavier databases, multiple production apps | Check stock |
| VPS 4 — Intel | 16 | 64 GB DDR4 ECC | 250 GB NVMe SSD | 1 Gbps, unmetered | ₹4,299/month | High-memory workloads and consolidated production servers | Check stock |
AMD EPYC 7C13 VPS
Dedicated KVM vCores on AMD EPYC 7C13 (up to 3.70 GHz) with DDR4 ECC memory, NVMe SSD and an unmetered 1 Gbps port.
| Plan | vCores | RAM | Storage | Network | Price | Good for | Buy |
|---|---|---|---|---|---|---|---|
| VPS 1 — AMD | 2 | 8 GB DDR4 ECC | 40 GB NVMe SSD | 1 Gbps, unmetered | ₹649/month | Websites, small APIs, bots, staging and VPN servers | Order |
| VPS 2 — AMD | 4 | 16 GB DDR4 ECC | 80 GB NVMe SSD | 1 Gbps, unmetered | ₹1,299/month | WooCommerce, Node.js/Python backends, Docker Compose stacks, CI runners | Order |
| VPS 3 — AMD | 8 | 32 GB DDR4 ECC | 150 GB NVMe SSD | 1 Gbps, unmetered | ₹2,499/month | Production databases, high-traffic sites, multi-container apps | Order |
| VPS 4 — AMD | 16 | 64 GB DDR4 ECC | 250 GB NVMe SSD | 1 Gbps, unmetered | ₹4,899/month | Large production workloads, SaaS platforms, analytics, in-memory caches | Order |
Prices are monthly in INR as listed on the SkyRainCloud store (verified 2026-11-14). Stock and final pricing are shown on the product page at checkout.
Debugging 502, 504 and Redirect Loops
- 502 Bad Gateway: Nginx cannot reach the app. Check the app is running and listening on the port in
proxy_pass(curl -I http://127.0.0.1:3000,ss -tlnp). Read/var/log/nginx/error.logfor "connection refused". - 504 Gateway Timeout: the app responded too slowly. Raise
proxy_read_timeoutfor that location or make the endpoint faster. - Too many redirects: the app does not know the original request was HTTPS. Pass
X-Forwarded-Protoand configure the framework to trust the proxy. With Cloudflare, use Full (strict) SSL mode. - Wrong site appears:
server_namedoes not match the hostname, so the default server answered. Check withsudo nginx -T | grep server_name. - Assets 404 under a path: the app is not configured for its base path, or the trailing slash on
proxy_passstrips a prefix the app expects.
Frequently Asked Questions
Can I host multiple websites on one VPS with Nginx?
proxy_pass to that port. Nginx routes requests by the Host header, so all sites share ports 80 and 443.Subdomains or paths: which is better for multiple apps?
api.example.com) are simpler because each app keeps its own root path. Paths (example.com/api/) work but require each app to know its base path.What does the trailing slash in proxy_pass do?
proxy_pass (e.g. http://127.0.0.1:8000/), Nginx replaces the matched location prefix with that URI, effectively stripping it. Without one (http://127.0.0.1:8000), the full original path is passed unchanged.Why does my app see 127.0.0.1 as every visitor's IP?
X-Forwarded-For and X-Real-IP from Nginx and configure the framework to trust the proxy at 127.0.0.1. Then it reads the client address from those headers.How do I proxy WebSockets with Nginx?
proxy_http_version 1.1 and pass Upgrade and Connection headers (via a map on $http_upgrade), and raise proxy_read_timeout for long-lived connections.How do I get SSL for several domains on one server?
certbot --nginx with multiple -d flags or once per site. Certbot edits each server block and sets up automatic renewal for all certificates.