Web Server Config Generator

Generate production-ready configs for Nginx, Apache, Caddy, and HAProxy

Templates:

General

Caddy Settings

Backend Servers

:

Custom Headers

No custom headers.

Caddy Configuration

Frequently Asked Questions

Nginx Configuration

Nginx is the most widely used web server, powering over 30% of all websites. Originally created by Igor Sysoev to handle the C10K problem (10,000 concurrent connections), Nginx uses an event-driven, non-blocking architecture that makes it exceptionally efficient at serving static files, proxying requests, and load balancing — all while using minimal memory.

Nginx configuration uses a hierarchical block structure with contexts: http contains server blocks (virtual hosts), which contain location blocks (URL matching rules). Directives are inherited from parent to child unless overridden.

server {
    listen 443 ssl http2;
    server_name netoz.au www.netoz.au;

    ssl_certificate     /etc/ssl/certs/netoz.au.pem;
    ssl_certificate_key /etc/ssl/private/netoz.au.key;

    # Security headers
    add_header Strict-Transport-Security "max-age=31536000" always;
    add_header X-Content-Type-Options "nosniff" always;

    # Static files with caching
    location /static/ {
        root /var/www/netoz;
        expires 30d;
        add_header Cache-Control "public, immutable";
    }

    # Reverse proxy to app server
    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;
    }
}

At NetOz, we use Nginx across our Adelaide hosting infrastructure for TLS termination, static asset serving, and reverse proxying to application servers. Its low resource footprint means we can handle thousands of concurrent connections per server without performance degradation.

Apache Configuration

Apache HTTP Server has been the backbone of the web since 1995 and remains the second most popular web server. Its key advantage is flexibility — Apache supports .htaccess files for per-directory configuration without server restarts, making it ideal for shared hosting environments where users need to control their own URL rewrites, authentication, and redirects.

<VirtualHost *:443>
    ServerName netoz.au
    ServerAlias www.netoz.au
    DocumentRoot /var/www/netoz/public

    SSLEngine on
    SSLCertificateFile    /etc/ssl/certs/netoz.au.pem
    SSLCertificateKeyFile /etc/ssl/private/netoz.au.key

    # Security headers
    Header always set Strict-Transport-Security "max-age=31536000"
    Header always set X-Content-Type-Options "nosniff"

    # Reverse proxy to Node.js app
    ProxyPreserveHost On
    ProxyPass / http://127.0.0.1:3000/
    ProxyPassReverse / http://127.0.0.1:3000/

    # Static files
    <Directory /var/www/netoz/public>
        Options -Indexes
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/netoz-error.log
    CustomLog ${APACHE_LOG_DIR}/netoz-access.log combined
</VirtualHost>

Apache uses a process/thread model (MPM) rather than Nginx's event loop. The event MPM is recommended for modern deployments — it handles keep-alive connections efficiently while maintaining compatibility with Apache's extensive module ecosystem. Key modules include mod_rewrite (URL rewriting), mod_proxy (reverse proxy), mod_ssl (TLS), and mod_security (WAF).

Reverse Proxy Setup

A reverse proxy sits between clients and your application servers, handling TLS termination, load balancing, caching, and request routing. It's the standard architecture for deploying web applications — your app listens on localhost while the reverse proxy handles the public-facing connection.

Typical reverse proxy architecture

Client → [HTTPS:443] → Nginx/Caddy → [HTTP:3000] → Node.js app

                                        → [HTTP:8000] → Python app

                                        → [HTTP:4000] → Go API

TLS Termination

The reverse proxy handles all SSL/TLS encryption, so your application servers don't need to manage certificates. This simplifies deployment — you manage one set of certificates on the proxy rather than configuring TLS in every application. Caddy does this automatically with built-in Let's Encrypt support.

Load Balancing

Distribute traffic across multiple backend servers for high availability. Nginx supports round-robin, least-connections, and IP-hash balancing. HAProxy adds advanced health checking, session persistence, and connection queuing.

# Nginx load balancing
upstream netoz_backends {
    least_conn;
    server 10.0.1.10:3000 weight=3;
    server 10.0.1.11:3000 weight=2;
    server 10.0.1.12:3000 backup;
}

Header Forwarding

When proxying requests, the application sees the proxy's IP instead of the client's. You must forward the original client information using headers like X-Real-IP, X-Forwarded-For, and X-Forwarded-Proto. Without these, your app can't determine the real client IP, detect HTTPS, or generate correct URLs.

WebSocket Proxying

WebSocket connections require special handling because they upgrade from HTTP to a persistent bidirectional connection. Both Nginx and Apache need explicit configuration to pass the Upgrade and Connection headers through to the backend.

# Nginx WebSocket proxy
location /ws/ {
    proxy_pass http://127.0.0.1:3000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}

Security tip: bind apps to localhost

Always bind your application servers to 127.0.0.1 rather than 0.0.0.0 when using a reverse proxy. This ensures the app is only accessible through the proxy, preventing direct access that bypasses your TLS, rate limiting, and security headers.

Manage your services with the Systemd Unit Generator, monitor SSL certificates with the SSL Expiry Monitor, or check your server's HTTP headers with the HTTP Header Checker.