Tool.Yun
Uirlisí úsáideacha do fhorbróirí
Áireamhán Amúchta
Bileog Cheat Bash
Bileog Cheat Comhréire JSONPath
Bileog Cheat Comhréire XPath
Bileog Cheat Docker
Bileog Cheat Jq
Bileog Cheat K8s
Bileog Cheat Markdown
Bileog Cheat Nano
Bileog Cheat Ordú Scáileáin
Bileog Cheat Ordú Tmux
Bileog Cheat Ordú Zellij
Bileog Cheat Ordú chmod
Bileog Cheat Powershell
Bileog Cheat Regex Choitianta
Bileog Cheat Roghnóirí CSS
Bileog Cheat Tiomnais Seimeantach Git
Bileog Cheat VIM
Bileog caimiléir Git
Bileog cheat Docker Compose
Bileog cheat Docker SWARM
Bileog cheat Dockerfile
Bileog cheat Regex
Bileog cheat Sed
NBileog Cheat ginx
Flipper Bonn
Roghnóir Cártaí
Rollóir Dísle
Roth an fhortún
Argon2 Hasher
Bcrypt
Beart Niceware go Frása Pasfhocail
Cripteagrafaíocht AOIS
Criptigh / díchriptiú téacs
Criptithe cruinneachán Ansible a dhíchriptiú
Criptiú Comhaid PGP
Criptiú PGP
Criptiú RSA
Criptiú Teaghrán Jasypt
Eochairghiniúint PGP
Gineadóir CSR
Gineadóir JWT
Gineadóir péire eochracha Ed25519
Gineadóir péirí eochracha ECDSA
Gineadóir teastais X509
Hais Comhaid
Hais téacs
Hmac gineadóir
Ionchódóir/Díchódóir Bech32
Parsálaí JWT
Parsálaí SAML
Parsálaí Teastais/Eochrach
Paseto/PASERK Poiblí/Príobháideach
Paseto/PASERK Áitiúil
RSA gineadóir eochair péire
Roinnt Rúnda Shamirs
Sínitheoir agus Fíoraitheoir RSA/DSA/ECDSA
Tiontaire Teastais SSL
Áireamhán CRC
Bailíochtóir GTIN
Díchódóir Cód QR
Gineadóir Faisnéise Teagmhála QR
Gineadóir barrachóid
Gineadóir cóid QR
Gineadóir cóid QR WiFi
Léitheoir Barrachóid
tools.epc-qrcode-generator.name
Bailíochtóir Cumadóireachta Docker
Docker Compose chuig comhad .env
Docker Compose go Quadlets
Docker compose go kubernetes
Docker iniúchta le haghaidh rith Docker
Déantóir Cumadóireachta Docker Traefik
Gineadóir Lipéad Dockerfile
Gineadóir RBAC Kubernetes
Lipéid Docker Pangolin
Rith Docker go Kubernetes
Rith Docker go Quadlets
Rith docker chuig tiontaire cumadóireachta Docker
Tiontaire Formáide Docker Compose
Tiontaire rith Docker Compose go Docker
Íoslódálaí Íomhánna Docker
Aláram Ama
Aláram Cron/Laethanta na Seachtaine
Comhaireamh síos
Cróniméadar
Cumaisc iCal
Cén Lá?
Gineadóir ICAL
Parsálaí Comhad ICAL
Tiontaire Crios Ama
Tiontaire Uimhreacha Seachtaine
Tiontaire dáta-am
Áireamhán Dáta+Fad
Áireamhán ETA
Áireamhán Fad
Áireamhán Laethanta
Áireamhán TTL
Ríomhaire Aclaíochta
Tiontaire Aonaid Achar
Tiontaire Aonaid Brú
Tiontaire Aonaid Fad
Tiontaire Aonaid Fuinnimh
Tiontaire Aonaid Fórsa
Tiontaire Aonaid Mais
Tiontaire Aonaid Toirte
Tiontaire Aonaid Uillinne
Tiontaire Cumhachta
Tiontaire Fuinnimh Bia
Tiontaire Luas
Tiontaire Luasghéaraithe
Tiontaire Minicíochta
Tiontaire Ráta Sreafa Toirte
Tiontaire Réimíreanna SI
Tiontaire Soilsiúcháin
Tiontaire teochta
Aibhsitheoir Cód/Scripteanna
Amaire Pomodoro
Bréigeoir Sonraí
CSS/JS Áilleachtú & Laghdaigh
Ceo Javascript
Dí-chomhbhrúiteoir/Díphacáileoir Javascript
Eagarthóir orduithe Cli
Gineadóir Favicon
Gineadóir GitIgnore
Gineadóir Mailto
Gineadóir Paraiméadair SQL
Gineadóir Rúnda Django
Gineadóir Scripteanna Tástála Ualaigh K6
Gineadóir Tréithe Git
Gineadóir Tábla Bunachar Sonraí
Json go Protobuf
Json go SQL INSERT
Json go Typescript
Miniféir SQL
Oscail gineadóir meta graf
SQL prettify agus formáid
Scoilteoir Comhad
Stacktrace níos deise
Tiontaire Comhad HEX
Tiontaire Lua
Tiontaire Lúb
Tástálaí API
Tástálaí Chomhéadain Swagger
Tástálaí Picomatch
Tástálaí Éalaithe ANSI
Tógálaí Cruthaithe Bunachar Sonraí
Tógálaí Teaghrán Ceangail Bunachar Sonraí
Áillitheoir Javascript
Éalaitheoir Teaghrán
Anailíseoir Tuairiscí DMARC
Bileog Cheat Sreangaithe RJ45 Cat6
Brathadóir Cineál Comhaid
Brathadóir/Díchódóir Tacair Charachtair Téacs
Consól Port Sraitheach
Cuardaitheoir airíonna LDAP ActiveDirectory
Díchódóir EMV TLV
Díchódóir Idirbhirt ETH
Díchódóir Safelink Outlook
Díchódóir Url Comhroinnte SharePoint
Eastóscóir aitheantais calóga sneachta
Faisnéis eochairchóid
Gineadóir TCPDump
Ionchódóir/Díchódóir Heicsidheachúlach
Leathnaitheoir URLanna Gearra
Léitheoir comhaid Parquet
Mascóir sonraí íogaire
Parsálaí Fianán
Parsálaí MSG Outlook
Parsálaí Ríomhphoist
Parsálaí Ríomhphoist Preabtha
Parsálaí URL
Tiontaire GZip/Díbhoilscithe
Tiontaire IdRéadaí MongoDB
Tiontaire Ionchódaithe MIME
Tiontaire Meán-Endian
Tiontaire SMART Raw
Tiontaire uimhir snámhphointe
Tástálaí DNS
Tástálaí HTTPS
Tástálaí Ilphlandúcháin DNS
Tástálaí Picteil Marbh
Tógálaí Ordú Nmap
Tógálaí URL
Áireamhán Friotóra
键盘测试器
Gineadóir Cód PIN
Gineadóir Frása Pas
Gineadóir NanoIDanna
Gineadóir Pasfhocal Diceware
Gineadóir UUIDs
Gineadóir comhartha
Gineadóir cóid OTP saor in aisce,
Gineadóir pasfhrása BIP39
Gineadóir uimhreacha
Gineadóir uimhreacha randamacha
Tiontaire UUID
Cineálacha MIME
Cóid stádais HTTP
Déantóir Blúirí Cuardaigh Téacs Url
Eagarthóir HTML WYSIWYG
Eolas gléas
Gabhálaí Url
Gineadóir Grádáin CSS
Gineadóir URL UTM
Gineadóir áitsealbhóirí SVG
Glantóir Html
Glantóir URL
HTML go XHTML
HTML go sonraí
Ionchódaigh/díchódaigh teaghráin formáidithe URL
Laghdaitheoir HTML
Parsálaí úsáideora-ghníomhaire
Roth Dathanna
Seiceálaí Codarsnachta Datha
Slabhra sluga a chruthú
Tiontaire Aonad CSS
Tiontaire CSS XPath
Tiontaire datha
Tiontaire picteilín REM
Áillitheoir CSS
Áillitheoir Html
Éalú aonáin HTML
Íomhá go CSS
Anailíseoir Méid Json
CSV go JSON
Cumaisc JSON
Cód Json go PHP
Difríocht JSON
Eagarthóir JSON
Iarratas Json
JSON Leacaitheoir/Díleacaitheoir
JSON Linter
JSON ceartaigh agus formáid
JSON chuig an Eintiteas Java
JSON go .env
JSON go C#
JSON go CSV
JSON go Go
JSON go MessagePack
JSON go Sonraí
JSON go TOML
JSON go TS
JSON go XML
JSON go réad
Json go PHP-Array
Json go Python
Json go SQL DDL
Json go Scéim
Laghdaigh JSON
Máistir sórtála JSON
ObjGen go JSON
PHP-Eagar go JSON
Pacáiste Teachtaireachta chuig JSON
Tiontaire JS go JSON
Tiontaire JSON go JS
Tiontaire JSON go YAML
Tiontaire teaghrán Json
Tástálaí Jq/JSONPath
tools.json-patch.name
Éalú Json/Unescape
Anailíseoir neart pasfhocal
Bileog Cheat ZPool
Cuardach seoladh MAC
Díchódóir ARPA
Díchódóir X-VR-SpamCause
Fiosrúcháin DNS
Forbróir raon IPv4
Formáideoir Nginx
Formáideoir Orduithe Shell
Geoshuíomh IP
Gineadóir Crontab
Gineadóir Cumraíochta Wireguard
Gineadóir DMARC DNS
Gineadóir DNS BIMI
Gineadóir DNS DKIM
Gineadóir DNS PTR
Gineadóir DNS SPF
Gineadóir FStab
Gineadóir HTAccess
Gineadóir Htpasswd/htaccess
Gineadóir Iptables
Gineadóir LogRotate Apache
Gineadóir Option43
Gineadóir Orduithe Múchta
Gineadóir Ordú Curl
Gineadóir Ordú UFW
Gineadóir Rsync
Gineadóir WPA PSK
Gineadóir port randamach
Gineadóir seoladh MAC
Gineadóir údaraithe bunúsach
IPv4-6/IPRange/CIDR in IPRange/CIDR/IPMask
IPv6 gineadóir ULA
Iarratais DNS/RDAP Cloudflare
Liosta Fo-líonra IPv4
Línearaitheoir Orduithe Shell
Mo Sheoladh IP
Neart Pasfhocal Zxcvbn
Ping
Seiceálaí DNSBL
Seiceálaí Whois
Sláintitheoir HAR
Slánuimhreacha chuig IPv4/IPv6
Tiontaire Punycode
Tiontaire Seoladh MAC
Tiontaire seoladh IPv4
Tiontaire seoladh Ipv6
Tástálaí Calafoirt TCP/UDP
Tástálaí Micreafóin
Tástálaí soicéad gréasáin
Uimhreacha Poirt
gineadóir líne ordaithe firewalld
tools.restic-command-generator.name
tools.url-redirection-checker.name
Áireamhán Chmod
Áireamhán Eisiaimh Fo-líonraí IP
Áireamhán Fo-líonra Amhairc
Áireamhán HDD
Áireamhán Iontaofachta RAID
Áireamhán RAID
Áireamhán RAID ZPOOL
Áireamhán Raoin IP ó CIDR Ipv4/6
Áireamhán Raon IPv4/6 go CIDR(anna)
Áireamhán Ráta Aistrithe Sonraí
Áireamhán fo-líonra Ipv6
Áireamhán subnet IPv4
Íoslódálaí il-naisc
Údarú SIP
Difríocht Marcáil anuas
Eagarthóir Markdown
Epub go Markdown
Gineadóir Tábla Marcála
Gineadóir toc Markdown
Greamaigh mar Markdown
HTML le marcáil síos
Lorem Ipsum Markdown
Marcáil síos ar shonraí
Marcáil síos go DOCX
Marcáil síos go HTML
Marcáil síos go Téacs
Réamhamharc marcála síos
tools.markdown-format-converter.name
Áilleoir Tábla Marcála
Amharcléiritheoir Cuar Triantánach/Cothromóideach
Measúnaí mata
OCR Matamaitice
Tiontaire Formáidí Matamaitice
Áireamhán Dénártha
Áireamhán leideanna
Comhbhrúiteoir PDF
Comhcheanglóir Pdf
Eastóscóir Téacs PDF
HTML go PDF
Pdf Criptithe
Pdf Eastóscóir Leathanach
Pdf Línearú/FastWeb
Pdf a dhíchriptiú agus a dhíghlasáil
Seiceáil sínithe PDF
Tógálaí Léirithe Cron
Bailíochtóir Luhn
Bailíochtóir agus Parsálaí ISBN
Bailíochtóir agus parsálaí IBAN
Bailíochtú Uimhreacha CBL
Comhoiriúnacht ceadúnas bogearraí
Cuardach Unicode
Cuardaitheoir Cód Tíre ISO 3166
Cuardaitheoir ISO 639
Foclóir Ar Líne
Mínigh an tOrdú Shell
Parsálaí agus formáidí fón
Seiceálaí Cárta Creidmheasa
Tiontaire Airgeadra
Tiontaire Cás Uachtarach RMB
Tiontaire Féilire
Treoirlínte Soilsithe IES
Áireamhán BMI
Áireamhán Luas Rith
Áireamhán SLA
TOML Linter
TOML go JSON
TOML go YAML
Csv go Sonraí
Excel go sonraí
Gineadóir ULID
Ionchódóir/díchódóir eagar heicsidheachúlach Base64
Ionchódóir/díchódóir teaghrán Base64
Normalaitheoir ríomhphoist
Ríomhaire Ídiú Fuinnimh agus Costais
Tiontaire Aonad Go Leor
Tiontaire Aonaid Stórála Sonraí
Tiontaire Carachtair Unicode go Eintitis Java
Tiontaire Comhordanáidí Geografacha
Tiontaire Formáid Athróg Comhdhlútha
Tiontaire airíonna
Tiontaire bonn slánuimhir
Tiontaire comhad base64 íoslódáil
Tiontaire dBm mW
Tiontaire uimhreacha Rómhánacha
Torrent go Maighnéad
Téacs go Unicode
Téacs go dénártha UTF-8
Tógálaí tagarmhairc
Áireamhán Cóimheas Gnéithe
Áireamhán achair gheografaigh
Áireamhán céatadánach
Aimsitheoir Línte Dúblacha
Aistritheoir Téacs
Athsholáthar Téacs Cliste agus Briseadh Líne
Bain téacs as HTML
Comhroinnteoir Nasc Sóisialta
Comparadóir Liostaí
Difríocht téacs
Déan Comparáid Clónna
Focail Ar Leith
Formáideoir Unicode
Gineadóir Ordú Sed
Gineadóir Sleachta
Gineadóir Téacs Ealaíne ASCII
Gineadóir an-mhaith
Gineadóir/Meirge Zalgo
Ionchódóir/Díchódóir Comhartha GPT
JSON go TOON
Liosta tiontaire
Léaráid Struchtúr Fillteán
Léitheoir RSVP
Meastóir Comharthaí GPT
Onnmhaireoir maighdeana mara
Pacáil comhaid le haghaidh AI
Roghnóir Emoji
Roghnóir Líní Rándamach
Scoilteoir Pras AI
Scrambalóir slabhra
Seiceálaí I agus L
Staitisticí téacs
TOON go JSON
Tabáil go Spásanna
Tiontaire Cód Morse
Tiontaire Leagan Amach Méarchláir
Tiontaire Rún
Tiontaire cás
Tástálaí Regex
Téacs chuig Ainmneacha Unicode
Téacs go aibítir NATO
Unicode go GSM-7
Áireamhán Levenshtein
Íomhá go hEalaín ASCII
Formáidiú XML
Linter XML
ObjGen go HTML
Tástálaí XPath
Tástálaí XSLT
XML go JSON
Cumasc YAML
Tiontaire YAML go JSON
YAML Leacaitheoir/Díleacaitheoir
YAML go TOML
YAML prettify agus formáid
Athraitheoir íomhá
Bain Cúlra na hÍomhá
Bain EXIF
Comparáid Íomhá
GIF go MP4
Inbhéartóir Dath Íomhá
Léitheoir cáilíochta EXIF/Meiteashonraí/GPS/JPEG íomhá
OCRúigh íomhá agus PDF
Réamhamharcóir SVG
Ríomhairigh íomhá
Taifeadta ceamara
Tiontaire Formáidí Íomhá
Tiontaire HEIC
Tiontaire ICO/PNG
Uiscemharc
Íomhá go SVG (potrace)

NBileog Cheat ginx

Cumraíocht Nginx agus orduithe úsáideacha

nginx is a web server, reverse proxy and load balancer. Configuration is a tree of contexts — main → events / http → server → location — and a directive is only valid in the contexts that define it.

🛠 Service & CLI

# check the configuration before you break production
sudo nginx -t

# print the entire resolved configuration, includes and all
sudo nginx -T

# reload without dropping connections
sudo nginx -s reload
sudo systemctl reload nginx

# start, stop, restart, status
sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx
sudo systemctl status nginx

# version, and the modules it was built with
nginx -V

# enable a site (Debian/Ubuntu layout)
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/

# watch the requests come in
sudo tail -f /var/log/nginx/access.log
sudo tail -f /var/log/nginx/error.log

💡 nginx -t then nginx -s reload — never restart on a live server if you can avoid it. A reload keeps existing connections alive; a restart drops them.

📁 Where Things Live

PathWhat it holds
/etc/nginx/nginx.confThe main file — worker settings and the http block
/etc/nginx/conf.d/*.confIncluded by default on RHEL-style installs
/etc/nginx/sites-available/Site configs on Debian/Ubuntu
/etc/nginx/sites-enabled/Symlinks to the sites that are actually live
/var/log/nginx/access.logEvery request
/var/log/nginx/error.logErrors, and anything the workers complain about
/var/www/htmlThe conventional document root

🧱 Config Skeleton

user www-data;
worker_processes auto;

events {
  worker_connections 1024;
}

http {
  include       /etc/nginx/mime.types;
  default_type  application/octet-stream;
  sendfile      on;
  keepalive_timeout 65;

  server {
    listen 80;
    server_name example.com;

    location / {
      root /var/www/html;
      index index.html;
    }
  }
}

🎧 listen & server_name

server {
  # plain HTTP
  listen 80;

  # HTTPS, with HTTP/2
  listen 443 ssl;
  http2 on;

  # IPv6 as well, or IPv6 only
  listen [::]:80;
  listen [::]:80 ipv6only=on;

  # the fallback server for requests that match no other server_name
  listen 80 default_server;

  # one name, several names, wildcards, or a regex
  server_name example.com;
  server_name example.com www.example.com;
  server_name *.example.com;
  server_name ~^(?<sub>.+)\.example\.com$;

  # requests that arrive with no Host header
  server_name "";
}

📄 Serving Files

server {
  listen 80;
  server_name example.com;
  root /var/www/example.com;
  index index.html index.htm;

  # try the file, then the directory, then fall back — the SPA pattern
  location / {
    try_files $uri $uri/ /index.html;
  }

  # cache fingerprinted assets hard
  location ~* \.(js|css|png|jpe?g|gif|svg|woff2?)$ {
    expires 1y;
    add_header Cache-Control "public, immutable";
    access_log off;
  }

  # a directory listing, when you actually want one
  location /downloads/ {
    autoindex on;
  }

  # a single file
  location = /robots.txt {
    root /var/www/example.com;
    log_not_found off;
  }
}

⚠️ root vs alias: root appends the whole URI to the path, alias replaces the matched prefix. With location /static/ { root /var/www; } a request for /static/a.png reads /var/www/static/a.png; with alias /var/www/assets/; it reads /var/www/assets/a.png. Always end an alias path with /.

📍 Location Matching

nginx does not pick locations top to bottom — it picks by modifier, in this order:

ModifierExampleMeaningPriority
=location = /healthExact match1 — wins immediately
^~location ^~ /static/Prefix match that stops regex matching2
~location ~ \.php$Case-sensitive regex, first match in file order3
~*location ~* \.(jpe?g)$Case-insensitive regex3
(none)location /images/Prefix match — the longest one wins if no regex did4
location = /health { return 200 "ok\n"; }   # checked first, cheapest
location ^~ /assets/ { root /var/www; }     # never falls through to the regex below
location ~* \.(png|jpg)$ { expires 30d; }
location / { try_files $uri $uri/ =404; }   # the catch-all

🔀 Redirects & Rewrites

# permanent redirect to the canonical host
server {
  listen 80;
  server_name www.example.com;
  return 301 https://example.com$request_uri;
}

# force HTTPS
server {
  listen 80;
  server_name example.com;
  return 301 https://$host$request_uri;
}

# temporary redirect of a single path
location /old-page {
  return 302 /new-page;
}

# rewrite with a captured segment
location /blog/ {
  rewrite ^/blog/(.*)$ /articles/$1 permanent;
}

# serve a maintenance page for everyone but your own IP
location / {
  if ($remote_addr != 203.0.113.7) {
    return 503;
  }
}

💡 Prefer return over rewrite — it is faster and clearer. Reach for rewrite only when you need to transform the path.

🔁 Reverse Proxy

server {
  listen 80;
  server_name app.example.com;

  location / {
    proxy_pass http://127.0.0.1:3000;

    # pass the client's details through to the app
    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;

    # timeouts: raise these for slow backends
    proxy_connect_timeout 60s;
    proxy_send_timeout    60s;
    proxy_read_timeout    60s;

    # buffering off for streaming responses (SSE, logs)
    proxy_buffering on;
  }

  # WebSockets need the upgrade headers
  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";
    proxy_read_timeout 3600s;
  }
}

⚠️ The trailing slash on proxy_pass changes everything. proxy_pass http://backend; forwards /api/users as /api/users; proxy_pass http://backend/; strips the matched location prefix first.

⚖️ Load Balancing

upstream backend {
  # least_conn;              # send to the server with the fewest connections
  # ip_hash;                 # sticky sessions by client IP
  # hash $request_uri;       # sticky by URI

  server 10.0.0.1:3000 weight=3;
  server 10.0.0.2:3000;
  server 10.0.0.3:3000 max_fails=3 fail_timeout=30s;
  server 10.0.0.4:3000 backup;

  keepalive 32;              # reuse upstream connections
}

server {
  listen 80;
  location / {
    proxy_pass http://backend;
    proxy_http_version 1.1;
    proxy_set_header Connection "";   # required for keepalive to work
  }
}
MethodBehaviour
(default)Round robin, honouring weight
least_connFewest active connections wins
ip_hashSame client IP always reaches the same server
hash <key>Distribute by any variable, e.g. $request_uri
random two least_connPick two at random, then the less busy one

🔐 HTTPS

server {
  listen 443 ssl;
  http2 on;
  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;
  ssl_prefer_server_ciphers off;
  ssl_session_cache shared:SSL:10m;
  ssl_session_timeout 1d;
  ssl_stapling on;
  ssl_stapling_verify on;

  # tell browsers to stay on HTTPS
  add_header Strict-Transport-Security "max-age=63072000" always;
}
# get and renew certificates automatically
sudo certbot --nginx -d example.com -d www.example.com
sudo certbot renew --dry-run

🚦 Limits & Access Control

http {
  # 10 MB of state ≈ 160k addresses; 10 requests/second per IP
  limit_req_zone $binary_remote_addr zone=req_limit:10m rate=10r/s;
  limit_conn_zone $binary_remote_addr zone=conn_limit:10m;

  server {
    # allow short bursts, queue the rest without delaying legitimate users
    location /api/ {
      limit_req zone=req_limit burst=20 nodelay;
      limit_conn conn_limit 10;
    }

    # the size of the largest upload you accept
    client_max_body_size 25m;

    # HTTP basic auth (htpasswd -c /etc/nginx/.htpasswd user)
    location /admin/ {
      auth_basic "Restricted";
      auth_basic_user_file /etc/nginx/.htpasswd;
    }

    # allow a subnet, deny the rest
    location /internal/ {
      allow 10.0.0.0/8;
      deny  all;
    }

    # do not serve dotfiles
    location ~ /\.(?!well-known) {
      deny all;
    }
  }
}

🗜 Performance

http {
  # compress text responses
  gzip on;
  gzip_vary on;
  gzip_min_length 1024;
  gzip_types text/plain text/css application/json application/javascript
             text/xml application/xml image/svg+xml;

  # kernel-level file sending
  sendfile on;
  tcp_nopush on;
  tcp_nodelay on;

  # keep connections around for reuse
  keepalive_timeout 65;
  keepalive_requests 1000;

  # cache open file handles
  open_file_cache max=10000 inactive=30s;
  open_file_cache_valid 60s;

  # a proxy cache for upstream responses
  proxy_cache_path /var/cache/nginx keys_zone=app_cache:10m max_size=1g inactive=60m;

  server {
    location / {
      proxy_cache app_cache;
      proxy_cache_valid 200 10m;
      add_header X-Cache-Status $upstream_cache_status;
    }
  }
}

🧪 Useful Variables

VariableHolds
$hostThe Host header, or the server name that matched
$uriThe normalised path, without the query string
$request_uriThe original path with the query string
$args / $arg_nameThe whole query string / one named parameter
$schemehttp or https
$remote_addrThe client’s IP address
$proxy_add_x_forwarded_forThe existing chain plus $remote_addr
$http_<name>Any request header, e.g. $http_user_agent
$request_methodGET, POST, …
$statusThe response status
$upstream_addrWhich backend actually served the request
$upstream_response_timeHow long the backend took
$request_timeHow long nginx took, start to finish

🩺 Troubleshooting

SymptomUsual cause
502 Bad GatewayThe backend is down, or refused the connection — check the app and proxy_pass
504 Gateway TimeoutThe backend is too slow — raise proxy_read_timeout, then fix the app
413 Request Entity Too LargeRaise client_max_body_size
403 Forbidden on a static fileThe worker user cannot read the path, or a directory lacks x
The wrong site is servedNo server_name matched, so the default_server answered
Changes have no effectThe config was never reloaded, or the file is not symlinked into sites-enabled
# see the config nginx is actually running, includes resolved
sudo nginx -T | less

# which worker user needs read access
ps -o user= -C nginx | sort -u

# turn up the error log while debugging
# error_log /var/log/nginx/error.log debug;

📚 Resources

  • Official documentation
  • Directive index
  • Variable index
  • Mozilla SSL configuration generator
  • Certbot — Let’s Encrypt