Nginx — Your Local Dev Reverse Proxy
Nginx is the world's most popular web server — learn to configure it from CLI:
Nginx as Reverse Proxy (next.js → port 3000):
```nginx
# nginx.conf
server {
listen 80;
server_name localhost;
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;
}
}
`
Nginx CLI Commands:
```cmd
nginx -t # Test config
nginx # Start server
nginx -s reload # Reload config (zero downtime)
nginx -s quit # Graceful shutdown
nginx -s stop # Immediate shutdown
`
Static File Hosting:
```nginx
server {
listen 8080;
root C:/projects/myapp/dist;
index index.html;
try_files $uri $uri/ /index.html;
}
`
Nginx is used by 400 million+ websites — it's essential knowledge for every web developer! 🌐
