Skip to content
ZeroServer.tools

nginx Config Generator

Generate nginx server block configs for static sites, reverse proxies, and HTTPS redirects.


server {
    listen 80;
    listen [::]:80;
    server_name www.example.com;
    return 301 https://example.com$request_uri;
}

server {
    listen 80;
    listen [::]:80;
    server_name example.com www.example.com;
    return 301 https://example.com$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name example.com;

    ssl_certificate     /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    ssl_protocols       TLSv1.2 TLSv1.3;
    ssl_ciphers         HIGH:!aNULL:!MD5;

    gzip on;
    gzip_vary on;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml;

    root /var/www/html;
    index index.html index.htm;

    location / {
        try_files $uri $uri/ =404;
    }

    access_log /var/log/nginx/example.com.access.log;
    error_log  /var/log/nginx/example.com.error.log;
}

How to use this nginx config

Save the generated config to /etc/nginx/sites-available/example.com, then enable it with ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/. Test with nginx -t and reload with systemctl reload nginx. For Let's Encrypt SSL, run certbot --nginx -d example.com first to obtain certificates — the paths are pre-filled for the Certbot convention.

Private & free — this tool runs entirely in your browser.

Recommended: IndieKit Ship your Next.js startup in days.affiliate

Related Developer Utilities tools