Reverse Proxy Config Generator

Build configurations for Nginx, Traefik, and Caddy.

Free · No sign-up · Use it instantly

tools/nginxReady

Reverse Proxy Server Generator

Generate production-ready proxy and SSL configurations for Nginx, Caddy, or Traefik.

NGINX.CONF PREVIEW
server {
    listen 80;
    listen [::]:80;
    server_name example.com www.example.com;

    # Redirect all HTTP requests to HTTPS
    return 301 https://$host$request_uri;
}

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

    # SSL TLS Handshake configurations
    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;
    ssl_prefer_server_ciphers on;

    client_max_body_size 64M;

    # Gzip Compression configurations
    gzip on;
    gzip_types text/plain text/css application/json application/javascript text/xml;
    gzip_min_length 1000;

    location / {
        # SPA fallback routing
        try_files $uri $uri/ /index.html;
    }
}

01 / How it works

Understanding Your Nginx Server Configuration

This Nginx config sets up a secure virtual host. It routes client traffic to your application root, configures asset compression via gzip, sets secure HTTP headers (HSTS, CSP), and handles Single Page Application (SPA) routing fallback so routes resolve correctly without throwing 404 errors.

Nginx Tuning, Caching, and Security Hardening Guide

Introduction to Nginx Performance Tuning

Nginx is a lightweight, asynchronous reverse proxy designed to handle thousands of concurrent connections with low memory usage. To maximize Nginx efficiency, developers must optimize worker configurations, buffer allocations, and connection keep-alives.

Essential Nginx Tuning Guidelines

  1. Adjust Worker Connections: Configure worker_processes auto to let Nginx allocate one worker per CPU core, and set worker_connections to at least 1024 to support concurrent clients.
  2. Enable Compression: Use Gzip or Brotli compression for text assets (CSS, JS, JSON, HTML). Ensure you set gzip_comp_level to a balanced level (4 to 6) to save bandwidth without overloading the CPU.
  3. Configure Browser Caching: Leverage cache-control headers for static assets. Long caching periods (e.g., Cache-Control "public, max-age=31536000, immutable") prevent repeat queries for unmodified bundles.
  4. Implement Redirect Chains: Cleanly redirect HTTP traffic to HTTPS using permanent 301 status codes.

Security Hardening for Nginx

  • Hide Server Version Info: Disable server_tokens to prevent Nginx from outputting its version number in error headers, making it harder for attackers to scan for known vulnerabilities.
  • Enforce HSTS: Add the Strict-Transport-Security header to force browsers to connect only via HTTPS.
  • Configure Secure SSL Cipher Suites: Restrict connections to TLS 1.2 and TLS 1.3, disabling old insecure protocols like SSLv3 and TLS 1.0.

02 / FAQ

Questions, answered.

How do I install the generated Nginx config?

Save the configuration inside /etc/nginx/sites-available/your-app, create a symlink to /etc/nginx/sites-enabled/your-app, and reload the server using "nginx -s reload".

What is worker_processes auto in Nginx?

This directive tells Nginx to launch one worker process per CPU core detected on the host system, ensuring optimal resource utilization.

How do I prevent Nginx from showing its version number?

Add the "server_tokens off;" directive inside the http, server, or location blocks of your nginx.conf configuration file.

What does try_files $uri $uri/ /index.html do?

This tells Nginx to check if a file exists at the requested path. If it does not, Nginx routes the request to index.html, which is critical for SPA client-side routing.

Why should I use Gzip or Brotli compression?

Compression reduces the size of text files sent over the network, dramatically speeding up page load speeds and improving Core Web Vitals.

How do I resolve "Nginx: [emerg] open() "/etc/nginx/nginx.conf" failed" errors?

This indicates Nginx cannot read its root config file, usually because of incorrect file permissions or running the validation command as a non-privileged user.

Can Nginx act as a load balancer?

Yes, using the upstream directive, Nginx can distribute incoming HTTP traffic across multiple backend application servers.

How do I enforce TLS 1.3 exclusively in Nginx?

Set "ssl_protocols TLSv1.3;" within your server block configurations, ensuring old protocols are disabled.

04 / Guides

Read next.

Ready when you are

Finished preparing your project?

Deploy it from Git with automatic builds, HTTPS and rollbacks on Deployxa.

All tools