How do I enable an Nginx configuration?
Create a file in /etc/nginx/sites-available/, create a symbolic link to /etc/nginx/sites-enabled/, 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 Configuring Nginx as a Reverse Proxy on EC2 Routing Traffic to Node.js
Nginx handles port management (80/443 while Node.js uses 3000), SSL termination, static file serving, load balancing, WebSocket proxying for Socket.io, and gzip compression. Node.js doesn't need to run as root or handle SSL directly.
Add a location /socket.io/ block with proxy_pass, proxy_http_version 1.1, and the Upgrade and Connection headers set to 'upgrade'. These headers are critical without them, WebSocket connections will fail.
They pass the client's real IP address to the Node.js app. Without them, Node.js sees Nginx's IP (127.0.0.1) instead of the actual client IP, which breaks IP-based features like rate limiting and logging.
Still have questions?
Browse all our FAQs or reach out to our support team
