nginx.ccWeb server troubleshooting desk

Full nginx config generator

Every nginxconfig.io option: multiple sites, PHP/Python/reverse proxy, WordPress/Drupal/Magento/Joomla, logging, performance, Docker. Outdated output is replaced by modern equivalents (marked “modernised”) and upstream bugs are fixed (marked “fixed”). Every option lives in the URL, ready to share. ← Scenario mode (simpler) · Credits & licence

Per-website config

example.com
Presets:
Server
Empty = /var/www/<domain>
modernised
HTTPS
modernised
fixed
modernised
modernised
Preload requires includeSubDomains, which is added automatically
PHP
nginx.ccAlways on upstream; switch off if PHP must read outside the site directory
fixed
Python
Turn off PHP first (only one of them per site)
Reverse proxy
Turn off PHP and Python first (only one of them per site)
Routing
Restrict
Logging
Empty = /var/log/nginx/<domain>.access.log
Empty = /var/log/nginx/<domain>.error.log
Onion
Tor Browser offers visitors the .onion version

Global config

Global
HTTPS
Added once per IP:port, on the first server
modernisedLet's Encrypt shut down OCSP in 2025, so it does nothing for LE certs; only useful with commercial CAs that still run OCSP
Security
Leave empty to omit
nginx.ccBrowsers removed the XSS auditor; when on this sends 0 (explicitly off) — never 1; mode=block
Python
Reverse proxy
Performance
fixed
Empty = no rule; e.g. 7d / 1M / max / off
Logging
NGINX
www-data on Debian/Ubuntu; nginx on nginx.org packages, Alpine and RHEL
Docker
modernised
modernised
Tools
fixed
Compatibility (nginx.cc)
Selects the http2 syntax; old versions lack QUIC, so HTTP/3 is ignored
nginx.cc
Share link (all options; parameters are interchangeable with nginxconfig.io share links)
https://nginx.cc/en/gen/pro
⬇ nginxconfig.tar.gz ⬇ zip
  • user is www-data (Debian/Ubuntu). For nginx.org packages, Alpine and RHEL use nginx.

Config files (7)

nginx.conf 54 lines
# Generated by nginx.cc (layout and options adapted from nginxconfig.io, MIT)
# See nginxcc.txt for the configuration share link

user www-data;
pid /run/nginx.pid;
worker_processes auto;
worker_rlimit_nofile 65535;

# Load modules
include /etc/nginx/modules-enabled/*.conf;

events {
    multi_accept on;
    worker_connections 65535;
}

http {
    charset utf-8;
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    server_tokens off;
    log_not_found off;
    types_hash_max_size 2048;
    types_hash_bucket_size 64;
    client_max_body_size 16M;

    # MIME
    include mime.types;
    default_type application/octet-stream;

    # Logging
    access_log off;
    error_log /dev/null;

    # SSL
    ssl_session_timeout 1d;
    ssl_session_cache shared:SSL:10m;
    ssl_session_tickets off;

    # Mozilla Intermediate configuration (Mozilla Server Side TLS 6.0)
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305;

    # CORS header for SVG/fonts (used at server level in general.conf)
    map $uri $nginxcc_cors {
        default "";
        "~*\.(?:svgz?|ttf|ttc|otf|eot|woff2?)$" "*";
    }

    # Load configs
    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}
sites-available/example.com.conf 48 lines
server {
    listen 443 ssl;
    listen [::]:443 ssl;
    http2 on;
    server_name example.com;
    set $base /var/www/example.com;
    root $base/public;

    # SSL
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

    # security
    include nginxcc-pro/security.conf;

    # logging
    access_log /var/log/nginx/example.com.access.log combined buffer=512k flush=1m;
    error_log /var/log/nginx/example.com.error.log warn;

    # index.php
    index index.php;

    # index.php fallback
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    # additional config
    include nginxcc-pro/general.conf;

    # handle .php
    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php-fpm.sock;
        include nginxcc-pro/php_fastcgi.conf;
        fastcgi_param PHP_ADMIN_VALUE "open_basedir=$base/:/usr/lib/php/:/tmp/";
    }
}

# HTTP redirect
server {
    listen 80;
    listen [::]:80;
    server_name example.com;
    include nginxcc-pro/letsencrypt.conf;
    location / {
        return 301 https://example.com$request_uri;
    }
}
nginxcc-pro/letsencrypt.conf 4 lines
# ACME-challenge
location ^~ /.well-known/acme-challenge/ {
    root /var/www/_letsencrypt;
}
nginxcc-pro/security.conf 11 lines
# security headers
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Content-Security-Policy "default-src 'self' http: https: ws: wss: data: blob: 'unsafe-inline'; frame-ancestors 'self';" always;
add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
add_header Strict-Transport-Security "max-age=63072000" always;

# . files
location ~ /\.(?!well-known) {
    deny all;
}
nginxcc-pro/general.conf 29 lines
# favicon.ico
location = /favicon.ico {
    log_not_found off;
}

# robots.txt
location = /robots.txt {
    log_not_found off;
}

# assets, media
location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|avif|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ {
    expires 7d;
}

# svg, fonts
location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ {
    expires 7d;
}

# CORS for SVG/fonts (map in nginx.conf; server level, so locations keep the security headers)
add_header Access-Control-Allow-Origin $nginxcc_cors;

# gzip
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
nginxcc-pro/php_fastcgi.conf 15 lines
# 404
try_files $fastcgi_script_name =404;

# default fastcgi_params
include fastcgi_params;

# fastcgi settings
fastcgi_index index.php;
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;

# fastcgi params
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_hide_header X-Powered-By;
nginxcc.txt 1 lines
https://nginx.cc/en/gen/pro

Setup

1. Download

  1. Go to the nginx config directory
    cd /etc/nginx
  2. Back up the current config
    sudo tar -czvf nginx_$(date +'%F_%H-%M-%S').tar.gz nginx.conf sites-available/ sites-enabled/ nginxcc-pro/
  3. Download and extract the generated config (or paste the base64 string from this page offline)
    curl -fsSL 'https://nginx.cc/api/pro/bundle.tar.gz?lang=en&stage=1' | sudo tar -xzf - -C /etc/nginx --no-same-owner
  4. Link the sites into sites-enabled
    sudo ln -sf /etc/nginx/sites-available/example.com.conf /etc/nginx/sites-enabled/example.com.conf

2. SSL init

  1. Create the ACME-challenge directory
    sudo mkdir -p /var/www/_letsencrypt
    sudo chown www-data /var/www/_letsencrypt

3. Certbot

  1. The bundle above is the stage-1 config: HTTPS sites temporarily serve HTTP only so validation can pass. Load it
    sudo nginx -t && sudo systemctl reload nginx
  2. Obtain the certificates (webroot)
    sudo certbot certonly --webroot -w /var/www/_letsencrypt -d example.com --register-unsafely-without-email --agree-tos -n
  3. Install the full config
    curl -fsSL 'https://nginx.cc/api/pro/bundle.tar.gz?lang=en' | sudo tar -xzf - -C /etc/nginx --no-same-owner
  4. Reload nginx after each renewal
    printf '#!/bin/sh\nnginx -t && systemctl reload nginx\n' | sudo tee /etc/letsencrypt/renewal-hooks/post/nginx-reload.sh
    sudo chmod a+x /etc/letsencrypt/renewal-hooks/post/nginx-reload.sh

4. Go live!

  1. Test and reload nginx
    sudo nginx -t && sudo systemctl reload nginx