EasyDebug.NET

Nginx Config Generator

Tick snippets to build a complete server block covering HTTPS, proxy, caching and 5 more

Tick the snippets you need; the full config updates live below. Static site and reverse proxy are mutually exclusive (both use location /), while WebSocket and upstream require the reverse proxy.

Server name
Proxy target
Proxy path
Certificate path
Private key path
Cache duration (days)
server {
    listen 80;
    server_name example.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    http2 on;
    server_name example.com;

    ssl_certificate /etc/nginx/ssl/example.com.crt;
    ssl_certificate_key /etc/nginx/ssl/example.com.key;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 1d;

    gzip on;
    gzip_vary on;
    gzip_min_length 1024;
    gzip_comp_level 6;
    gzip_types text/plain text/css text/xml application/json application/javascript application/xml+rss application/rss+xml image/svg+xml;

    location ~* \.(?:jpg|jpeg|png|gif|ico|webp|svg|css|js|woff2?)$ {
        expires 30d;
        add_header Cache-Control "public, immutable";
        access_log off;
    }

    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Something broken or missing?

Send feedback
Author's Blog
Share an idea