How do I enable a new Nginx config?
Create the config in /etc/nginx/sites-available/, create a symlink to /etc/nginx/sites-enabled/ with ln -s, remove the default site, test with sudo nginx -t, and restart with sudo systemctl restart nginx.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Installing and Configuring Nginx on Ubuntu for Node.js Deployment
Run sudo apt update and sudo apt install -y nginx. Start with sudo systemctl start nginx, enable with sudo systemctl enable nginx. Verify by visiting http://your-ip in a browser to see the welcome page.
nginx.conf is the main config. sites-available/ contains all site configs. sites-enabled/ contains symlinks to enabled sites. conf.d/ has additional configs. Create configs in sites-available, symlink to sites-enabled, remove the default, test, and restart.
Create a server block with listen 80, server_name your domain, and a location / block with proxy_pass http://localhost:3000. Add proxy_set_header directives for Host, X-Real-IP, X-Forwarded-For, X-Forwarded-Proto, and Upgrade/Connection headers for WebSocket support.
Still have questions?
Browse all our FAQs or reach out to our support team
