# nginx Configuration Basics

Common server blocks.

```nginx
server {
    listen 80;
    server_name example.com www.example.com;
    return 301 https://example.com$request_uri;
}
server {
    listen 443 ssl;
    server_name example.com;
    ssl_certificate     /etc/ssl/example.pem;
    ssl_certificate_key /etc/ssl/example.key;
    root /var/www/site;
    index index.html;
    gzip on;

    location / { try_files $uri $uri/ =404; }
    location /api/ { proxy_pass http://127.0.0.1:3000; proxy_set_header Host $host; }
}
```

```bash
sudo nginx -t            # test configuration
sudo nginx -s reload     # reload without downtime
```
