DevBolt
Processed in your browser. Your data never leaves your device.

How do I generate an Nginx configuration file online?

Choose a preset (static site, reverse proxy, SPA, Node.js, PHP, load balancer, HTTPS) and customize server blocks, SSL/TLS settings, gzip compression, security headers, rate limiting, and upstream servers. The tool generates a complete nginx.conf you can copy or download. Everything runs in your browser.

Generate reverse proxy config
Input
Type: Reverse Proxy
Domain: api.example.com
Upstream: localhost:3000
SSL: yes
Output
server {
  listen 443 ssl http2;
  server_name api.example.com;

  ssl_certificate /etc/ssl/cert.pem;
  ssl_certificate_key /etc/ssl/key.pem;

  location / {
    proxy_pass http://localhost:3000;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP
      $remote_addr;
  }
}
← Back to tools

Nginx Config Generator

Generate nginx configuration files with a visual builder. Choose a preset, configure server settings, SSL, gzip, security headers, and location blocks — then copy or download the config.

Presets

Server Basics

SSL / TLS

Performance

Security

Proxy Settings

Rate Limiting

Load Balancing (Upstream)

Logging

Location Blocks

Generated Config

# nginx.conf
# Generated by DevBolt Nginx Config Generator
# https://devbolt.dev/tools/nginx-config

server {
    listen 80;
    listen [::]:80;
    server_name example.com;

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

    # Security headers
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-XSS-Protection "1; mode=block" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;

    # Gzip compression
    gzip on;
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_min_length 256;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;

    client_max_body_size 10m;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

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

}

Tips & Best Practices

Pro Tip

Enable gzip for text-based assets to save 60-80% bandwidth

Add gzip on; with gzip_types text/plain text/css application/json application/javascript text/xml. Don't gzip images or already-compressed files (gzip_min_length 256). For modern browsers, consider adding Brotli (ngx_brotli) for an additional 15-20% improvement over gzip.

Common Pitfall

proxy_pass with a trailing slash behaves differently

proxy_pass http://backend/ (with slash) strips the location prefix. proxy_pass http://backend (without slash) preserves it. Example: location /api/ with proxy_pass http://backend/ forwards /api/users as /users. Without the slash, it forwards as /api/users. This subtle difference causes routing bugs.

Real-World Example

Serve SPAs with try_files for client-side routing

Single-page apps need all routes to serve index.html: location / { try_files $uri $uri/ /index.html; }. This serves existing static files directly but falls back to index.html for any path your JavaScript router handles. Without this, refreshing /dashboard returns a 404.

Security Note

Hide Nginx version and add security headers

server_tokens off; hides the Nginx version from response headers. Add add_header X-Content-Type-Options nosniff; add_header X-Frame-Options DENY; add_header Referrer-Policy strict-origin-when-cross-origin; to prevent MIME sniffing, clickjacking, and referrer leakage. Use DevBolt's Security Headers tool for the full set.

Frequently Asked Questions

How do I generate an Nginx configuration file?
Select a preset template (Static Site, Reverse Proxy, SPA, Load Balancer, or PHP) and customize settings using the visual builder. Configure server name, listen port, root directory, SSL paths, proxy upstream addresses, and additional directives. The generator produces a complete nginx.conf server block. For reverse proxy setups, it includes proxy_pass, proxy_set_header, WebSocket support, and timeouts. For static sites, it adds gzip compression, cache headers, and try_files. Download or copy the configuration directly. All generation happens in your browser.
How do I configure Nginx as a reverse proxy?
The essential directives are: listen 80 or 443 for SSL, server_name to match the domain, and a location block with proxy_pass pointing to the backend like http://localhost:3000. Important headers include proxy_set_header Host $host, X-Real-IP, X-Forwarded-For, and X-Forwarded-Proto. For WebSocket support, add proxy_http_version 1.1, proxy_set_header Upgrade $http_upgrade, and Connection upgrade. DevBolt's generator includes all these settings in the reverse proxy preset.
How do I enable SSL/TLS in Nginx?
Add an SSL server block on port 443 with ssl_certificate and ssl_certificate_key directives pointing to your cert files. Set ssl_protocols to TLSv1.2 and TLSv1.3 only, use strong ciphers, and add HSTS. Create a separate port 80 block that redirects HTTP to HTTPS. Use Let's Encrypt with Certbot for free automated SSL certificates. DevBolt's generator produces all SSL settings correctly configured and ready for deployment.

Related Generate Tools