Host a website on your VPS with Nginx and free SSL
Host a website on your VPS with Nginx and free SSL
Prerequisites
- A domain whose A record points to your VPS IP โ see Point your domain at your server.
- Ports 80 and 443 open (firewall guide).
Install Nginx
apt install nginx -y
Create a site
Put files in /var/www/example.com and create /etc/nginx/sites-available/example.com:
server {
listen 80;
server_name example.com www.example.com;
root /var/www/example.com;
index index.html;
}
Enable and reload:
ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
nginx -t && systemctl reload nginx
Free HTTPS
apt install certbot python3-certbot-nginx -y
certbot --nginx -d example.com -d www.example.com
Certbot installs the certificate and renews it automatically. Test renewal with certbot renew --dry-run.
Reverse proxy to an app
Replace root/index with location / { proxy_pass http://127.0.0.1:3000; } to serve a Node.js or Python app.
Was this not what you needed?
Tell us what you're trying to do and our team will help directly.
Open a support ticket Ask on Discord