Web Hosting
Nginx Reverse Proxy & SSL for Node.js Apps
Running Node.js apps safely on domains requires a reverse proxy.
1. Install Nginx and Certbot
bash
sudo apt update
sudo apt install nginx certbot python3-certbot-nginx -y2. Configure Nginx
Create a new configuration file for your site:
bash
sudo nano /etc/nginx/sites-available/myappPaste the following, assuming your Node.js app runs on port 3000:
nginx
server {
listen 80;
server_name mydomain.com www.mydomain.com;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}3. Enable and SSL
Make sure to deactivate the default Nginx configuration so it doesn't conflict:
bash
sudo unlink /etc/nginx/sites-enabled/defaultNow enable your site and apply the SSL certificate:
bash
sudo ln -s /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
# Generate SSL Let's Encrypt Certificate
sudo certbot --nginx -d mydomain.comKVM Linux VPS
Looking for the right Linux VPS?
Put your project into practice right away: Our KVM VPS provide full root access, lightning-fast NVMe storage, and reliable KVM isolation. Flexible prepaid billing with no subscription and personal Discord support.
Full Root Access (SSH)
Datacenter NVMe SSD
4+ Tbps DDoS Protection
100% Prepaid (No Subscription)