Free tools that run in your browser. Use any tool without an account.

Favourites Cart
Sign in
Join free

Nginx Config Generator

Server blocks

  • Free
  • Runs in your browser
  • No account needed

It creates ready-to-use Nginx server blocks for a domain, including a port 80 HTTP redirect, HTTPS block with TLS 1.2 and 1.3 plus HTTP/2, optional gzip, and 30-day browser caching for static files.

Nginx config
# Send all plain HTTP visits to HTTPS
server {
    listen 80;
    listen [::]:80;
    server_name example.com www.example.com;
    return 301 https://example.com$request_uri;
}

# Redirect www.example.com to example.com
server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name www.example.com;
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    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;

    add_header X-Content-Type-Options "nosniff" always;
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;
    add_header Strict-Transport-Security "max-age=31536000" always;

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

    location / {
        proxy_pass http://127.0.0.1:3000;
        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;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}
Save it as
/etc/nginx/sites-available/example.com
Then run
sudo certbot certonly --nginx -d example.com -d www.example.com
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

Get the certificate first (the certbot line below, which needs the python3-certbot-nginx package), because Nginx will not start with certificate paths that do not exist yet. Always run sudo nginx -t before reloading.

Runs in your browser. Your files and values are not sent to us. Report a problem
Advertisement

About the Nginx Config Generator

This tool builds Nginx server blocks in your browser with no upload. You pick Domain, Site type, App port, Website folder and toggles for HTTPS, www handling, gzip, 30-day caching and security headers. The generator writes three server blocks: a port 80 block that sends visitors to HTTPS, a 301 redirect for www or non-www, and the main HTTPS block with Let's Encrypt paths, TLS 1.2 and 1.3, and HTTP/2. Reverse proxy mode sets proxy headers, preserves the real IP and supports WebSockets. The page updates results as you type and you can copy the config or share a link that reopens your inputs. The tool shows the certbot command and warns you to get the certificate first, because Nginx will not start with missing cert paths. Always run sudo nginx -t before reloading Nginx.

How to use it

  1. 1Choose Domain and Site type.
  2. 2Set App port and Website folder, and pick HTTPS and www handling.
  3. 3Toggle gzip, caching and security headers.
  4. 4Copy the generated config, run certbot if using Let's Encrypt, then test with sudo nginx -t and reload.
Advertisement

Worked example

Inputs: Domain: example.com Site type: Reverse proxy to an app (Node.js) App port: 3000 Website folder: /var/www/example HTTPS: HTTPS with Let's Encrypt certificates www: Send www to example.com Gzip compression: On Cache images, CSS and JS for 30 days: Yes Security headers: Add them Generated Nginx config: server { 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 www.example.com; return 301 https://example.com$request_uri; } server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name example.com; root /var/www/example; 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; gzip on; location / { proxy_pass http://127.0.0.1:3000; 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; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } location ~* \.(?:css|js|jpg|jpeg|gif|png|svg|ico)$ { expires 30d; add_header Cache-Control "public"; } add_header X-Content-Type-Options nosniff; add_header X-Frame-Options SAMEORIGIN; add_header Referrer-Policy no-referrer-when-downgrade; add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"; } Certbot example to get certificates first: sudo certbot --nginx -d example.com -d www.example.com # needs python3-certbot-nginx Then test and reload: sudo nginx -t sudo systemctl reload nginx

How it works

Writes server blocks for Nginx: a port 80 block that sends visitors to HTTPS, a block that redirects the www or non-www name with a 301, and the main block with Let's Encrypt certificate paths, TLS 1.2 and 1.3, HTTP/2, optional gzip, 30-day browser caching of static files and security headers (nosniff, SAMEORIGIN frames, a referrer policy and HSTS on HTTPS)Reverse proxy mode forwards the Host, real IP and protocol headers and supports WebSockets

Source: Nginx documentation - switches and testingCertbot documentation - obtain certificatesMozilla Server Side TLS recommendations. Last checked 6 November 2026.

What it is good for

  • Runs fully in your browser with no upload.
  • Generates HTTP, HTTPS and www redirects plus main server block.
  • Includes gzip, 30-day static caching and common security headers.
  • Only generates a single server block set per run, not multi-site pools.
  • You must obtain TLS certificates yourself before Nginx will start with the supplied paths.
Advertisement

Questions people ask

Will this tool install TLS certificates for me?

No. The tool only outputs config text and shows the certbot command. You must run certbot or another ACME client to obtain certificates and place them at the paths shown.

Is my domain data sent to a server?

No, this tool runs in your browser and does not upload inputs. Still check your browser settings and network policies if you need stricter privacy.

Where should I save the generated file on my server?

On Debian and Ubuntu save it to /etc/nginx/sites-available/your-site then symlink to /etc/nginx/sites-enabled/. Some systems use /etc/nginx/conf.d/ instead. Run sudo nginx -t before reloading.

How do I test the generated config before applying it?

Run sudo nginx -t to test syntax. If the test passes, reload with sudo systemctl reload nginx or sudo nginx -s reload to apply the change.

Will reverse proxy mode handle WebSockets?

Yes. The generated proxy block includes proxy_http_version 1.1 and Upgrade and Connection headers. You should still confirm upstream timeouts and keepalive settings for your app.

Do the TLS lines work on every Nginx build?

Not always. Features like TLS 1.3 require a compatible OpenSSL and Nginx build. Check nginx -V and adjust protocols and ciphers to match your build.

Help keep every tool free

FreeToolr stays free because people help it grow. Share a tool you like, tell us what to build next, or support us on Ko-fi.

Advertisement
Advertisement