Tool.Yun
أدوات مفيدة للمطورين
CSV إلى JSON
JSON Linter
JSON إلى .env
JSON إلى C#
JSON إلى CSV
JSON إلى Go
JSON إلى MessagePack
JSON إلى TOML
JSON إلى TS
JSON إلى XML
JSON إلى object
JSON إلى البيانات
JSON إلى كيان Java
Json Escaper/Unescaper
Json إلى PHP-Array
Json إلى Python
Json إلى SQL DDL
Json إلى مخطط
PHP-Array إلى JSON
tools.json-patch.name
أداة التحويل الى نص بتنسيق JSON
أداة ترتيب JSON
استعلام Json
تجميل وتنسيق JSON
تحويل Json إلى كود PHP
تحويل ObjGen إلى JSON
حزمة الرسائل إلى JSON
دمج JSON
محرر JSON
محلل حجم JSON
محول JS إلى JSON
محول JSON إلى JS
محول JSON إلى YAML
مصغر JSON
مقارنة JSON
مُختبر Jq/JSONPath
مُسطّح/غير مُسطّح JSON
TOML إلى JSON
تحويل TOML إلى YAML
تومل لينتر
دليل أوامر Tmux
دليل أوامر Zellij
دليل أوامر الشاشة
دليل مختصر لـ PowerShell
ملخص أوامر Git
ورقة الغش Jq
ورقة الغش Markdown
ورقة الغش Nginx
ورقة الغش Sed
ورقة الغش VIM
ورقة الغش الخاصة بـ Docker
ورقة الغش الخاصة بـ Docker SWARM
ورقة الغش الخاصة بـ Dockerfile
ورقة الغش الخاصة بـ Regex
ورقة الغش باش
ورقة الغش لـ Docker Compose
ورقة الغش لقواعد بناء جملة JSONPath
ورقة الغش نانو
ورقة غش Git Semantic Commit
ورقة غش K8s
ورقة غش تعبيرات عادية شائعة
ورقة غش لأمر chmod
ورقة غش لقواعد XPath
ورقة غش لمحددات CSS
XML Linter
XML إلى JSON
تحويل ObjGen إلى HTML
منسق XML
مُختبر XPath
مُختبر XSLT
أداة اختيار البطاقات
رمي النرد
عجلة الحظ
قاذفة العملة
tools.epc-qrcode-generator.name
فك رمز الاستجابة السريعة
قارئ الباركود
مولد الباركود
مولد رمز الاستجابة السريعة (QR Code)
مولد رمز الاستجابة السريعة (QR Code) للشبكة اللاسلكية
مولد رمز الاستجابة السريعة (QR Code) لمعلومات الاتصال
مُتحقق GTIN
أداة البحث عن رموز البلدان وفقًا لمعيار ISO 3166
إرشادات الإضاءة من IES
باحث ISO 639
بحث يونيكود
توافق ترخيص البرنامج
حاسبة اتفاقية مستوى الخدمة
حاسبة سرعة الجري
حاسبة مؤشر كتلة الجسم
شرح أوامر shell
قاموس إلكتروني
محقق أرقام ضريبة القيمة المضافة
محقق لوهن
محلل ومدقق رقم الحساب المصرفي الدولي (IBAN)
محلل ومنسق رقم الهاتف
محول الأحرف الكبيرة من RMB
محول التقويم
محول العملات
مدقق بطاقات الائتمان
مُحقق ومحلل ISBN
أي يوم؟
إنذار الوقت
إنذار كرون/أيام الأسبوع
العد التنازلي
حاسبة TTL
حاسبة الأيام
حاسبة التاريخ والمدة
حاسبة المدة
حاسبة وقت الوصول المتوقع (ETA)
دمج iCal
محلل ملفات ICAL
محول أرقام الأسبوع
محول المنطقة الزمنية
محول الوقت والتاريخ
مقياس الزمن
مولد ICAL
باسيتو/باسرك المحلية
باسيتو/باسرك عام/خاص
بايتات Niceware إلى عبارة مرور
بيكريبت
تجزئة النص
تشفير / فك تشفير النص
تشفير AGE
تشفير PGP
تشفير RSA
تشفير الملفات باستخدام PGP
تشفير سلسلة Jasypt
حاسبة CRC
فك تشفير Ansible Vault Crypt
محلل JWT
محلل SAML
محلل الشهادة/المفتاح
محول شهادة SSL
مشاركة أسرار شامير
مشفر/مفكك شفرة Bech32
مولد HMAC
مولد JWT
مولد المسؤولية الاجتماعية للشركات
مولد زوج المفاتيح Ed25519
مولد زوج مفاتيح ECDSA
مولد زوج مفاتيح RSA
مولد شهادة X509
مولد مفاتيح PGP
مُوقِّع ومُتحقق RSA/DSA/ECDSA
هاشر Argon2
هاشر الملفات
Json إلى Protobuf
Json إلى SQL INSERT
Stacktrace أجمل
أداة إخفاء جافا سكريبت
أداة إنشاء قواعد البيانات
أداة فك تشفير/فك حزم JavaScript
اختبار واجهة المستخدم Swagger
اختبارات API
تجميل وتنسيق SQL
تحويل Json إلى TypeScript
تمييز الأكواد/البرامج النصية
تنسيق وتصغير ملفات CSS/JS
جهاز اختبار الهروب ANSI
جهاز اختبار بيكوماتش
مؤقت بومودورو
محرر أوامر سطر الأوامر
محول الاقتباس
محول التجعيد
محول ملفات HEX
مزور البيانات
مقسم الملفات
منشئ سلسلة اتصال قاعدة البيانات
مولد Mailto
مولد أسرار جانجو
مولد الرموز المفضلة
مولد تجاهل Git
مولد جداول قواعد البيانات
مولد سمات Gita
مولد علامات Open Graph
مولد معلمات SQL
مولد نصوص اختبار التحميل K6
مُحسِّن جافا سكريبت
مُصغّر SQL
هارب الخيط
IPv4-6/IPRange/CIDR في IPRange/CIDR/IPMask
tools.restic-command-generator.name
tools.url-redirection-checker.name
أداة اختبار الميكروفون
أداة اختبار منافذ TCP/UDP
أداة تنزيل الروابط المتعددة
أرقام المنافذ
اختبار Websocket
استعلامات Cloudflare DNS/RDAP
استعلامات DNS
الأعداد الصحيحة إلى IPv4/IPv6
التحقق من عنوان MAC
بينغ
تحديد الموقع الجغرافي عبر IP
تفويض SIP
جهاز فك تشفير ARPA
حاسبة RAID
حاسبة ZPOOL RAID
حاسبة أمر Chmod
حاسبة استبعاد شبكات IP الفرعية
حاسبة الشبكات الفرعية المرئية
حاسبة الشبكات الفرعية لـ IPv4
حاسبة الشبكة الفرعية IPv6
حاسبة القرص الصلب
حاسبة معدل نقل البيانات
حاسبة موثوقية RAID
حاسبة نطاق IP من CIDR إلى IP الإصدار 4/6
حاسبة نطاق IPv4/6 إلى CIDR(s)
عنوان IP الخاص بي
فك تشفير X-VR-SpamCause
قائمة الشبكات الفرعية IPv4
قوة كلمة المرور Zxcvbn
محلل قوة كلمة المرور
محول Punycode
محول عناوين IPv4
محول عنوان IPv6
محول عنوان MAC
مدقق DNSBL
مدقق Whois
موسع نطاقات IPv4
مولد Apache LogRotate
مولد Crontab
مولد DKIM DNS
مولد DNS BIMI
مولد DNS DMARC
مولد FStab
مولد HTAccess
مولد Htpasswd/htaccess
مولد Iptables
مولد Rsync
مولد SPF DNS
مولد WPA PSK
مولد أوامر Curl
مولد أوامر UFW
مولد أوامر الإيقاف
مولد أوامر جدار الحماية
مولد الخيار 43
مولد تكوين Wireguard
مولد عناوين IPv6 ULA
مولد عناوين MAC
مولد مصادقة أساسية
مولد منفذ عشوائي
مولد نظام أسماء النطاقات PTR
مُحَوِّل أوامر الصدفة
مُنسِّق أوامر الصدفة
مُنسّق Nginx
ورقة الغش ZPool
يحتوي على مطهر
أداة تغيير حجم الصورة
إزالة EXIF
إزالة خلفية الصورة
التعرف الضوئي على الحروف للصور وملفات PDF
تحويل GIF إلى MP4
تحويل الصورة إلى SVG (potrace)
عاكس ألوان الصورة
علامة مائية
قارئ جودة الصور EXIF/Metadata/GPS/JPEG
قص الصورة
محول HEIC
محول ICO/PNG
محول صيغ الصور
مسجل الكاميرا
معاينة ملفات SVG
مقارنة الصور
أداة إنشاء أوامر Nmap
أداة اختبار HTTPS
أداة اختبار انتشار نظام أسماء النطاقات (DNS)
أداة اختبار نظام أسماء النطاقات (DNS)
باحث خصائص LDAP في ActiveDirectory
حاسبة المقاومة
دليل مختصر لتوصيل كابلات RJ45 Cat6
فك تشفير EMV TLV
فك تشفير Outlook Safelink
فك تشفير عنوان URL لمشاركة Sharepoint
فك تشفير معاملات ETH
قارئ ملفات الباركيه
قناع البيانات الحساسة
كاشف نوع الملف
كاشف/فك تشفير مجموعة أحرف النص
محلل MSG في Outlook
محلل البريد الإلكتروني
محلل البريد الإلكتروني المرتد
محلل تقارير DMARC
محلل عنوان URL
محلل ملفات تعريف الارتباط
محول GZip/Deflate
محول SMART Raw
محول أرقام الفاصلة العائمة (float number)
محول الطرف الأوسط
محول ترميز MIME
محول معرف كائن MongoDB
مختبر البكسلات الميتة
مستخرج هوية ندفة الثلج
مشفر/فك تشفير سداسي عشري
معلومات رموز المفاتيح
منشئ عناوين URL
مولد TCPDump
مُوسِّع عناوين URL القصيرة
وحدة التحكم بالمنفذ التسلسلي
键盘测试器
كمبيوتر اللياقة البدنية
محول الإضاءة
محول التردد
محول التسارع
محول السرعة
محول الطاقة
محول بادئات النظام الدولي للوحدات
محول درجات الحرارة
محول طاقة الطعام
محول معدل التدفق الحجمي
محول وحدات الحجم
محول وحدات الزاوية
محول وحدات الضغط
محول وحدات الطاقة
محول وحدات الطول
محول وحدات القوة
محول وحدات الكتلة
محول وحدات المساحة
حاسبة المسافة الجغرافية
حاسبة النسب المئوية
حاسبة نسبة العرض إلى الارتفاع
صانع مقاييس الأداء
Excel إلى البيانات
استهلاك الطاقة ونفقاتها في الكمبيوتر
تحويل CSV إلى بيانات
تحويل الملفات إلى Base64
تحويل نص إلى تمثيله الثنائي في UTF-8
تورنت إلى مغناطيس
محول أحرف Unicode إلى كيانات جافا
محول الأرقام الرومانية
محول الأنظمة العددية
محول الإحداثيات الجغرافية
محول الخصائص
محول الوحدات المتعددة
محول تنسيق متغيرات البيئة
محول ديسيبل ميلي واط
محول وحدة تخزين البيانات
مرمز Base64 للنصوص
مولد ULID
مُشفِّر/فك تشفير مصفوفة سداسية عشرية Base64
مُعَيِّر البريد الإلكتروني
نص إلى الترميز الموحد (Unicode)
محول UUID
مولد الأرقام العشوائية
مولد الاختصارات الرقمية (Numeronym)
مولد الرمز البريدي
مولد الرموز
مولد رمز كلمة مرور لمرة واحدة (OTP)
مولد عبارات مرور BIP39
مولد عبارة المرور
مولد كلمة المرور Diceware
مولد معرفات NanoIDs
مولد معرفات UUIDs
JSON إلى TOON
Unicode إلى GSM-7
أداة البحث عن الخطوط المكررة
أنا و ل تشيكر
إحصائيات النص
اختبار التعابير العادية
استخراج النص من HTML
الصورة إلى فن ASCII
انتقل إلى المسافات باستخدام زر Tab
تحويل TOON إلى JSON
تحويل النص إلى أسماء Unicode
تعتيم سلسلة نصية
حاسبة ليفينشتاين
حزم الملفات للذكاء الاصطناعي
قارئ تأكيد الحضور
كلمات مميزة
مترجم النصوص
محدد سطور عشوائية
محول الرونية
محول القوائم
محول تخطيط لوحة المفاتيح
محول حالة الأحرف
محول شفرة مورس
مخطط هيكل المجلد
مشاركة الروابط الاجتماعية
مصدر حورية البحر
مقارنة الخطوط
مقارنة القوائم
مقارنة النصوص
مقدر رمز GPT
مقسم مطالبات الذكاء الاصطناعي
منتقي الرموز التعبيرية
مولد أوامر Sed
مولد الاستشهادات
مولد نص فني ASCII
مولد نصوص Lorem ipsum
مولد/بانر زالغو
مُستبدل النص الذكي وقاطع الأسطر
مُشفِّر/فك تشفير رمز GPT
مُنسّق Unicode
نص إلى أبجدية الناتو
أنواع الوسائط (MIME types)
الصورة إلى CSS
تحويل HTML إلى XHTML
تحويل HTML إلى بيانات
ترميز/فك ترميز السلاسل النصية بصيغة ترميز عنوان URL
تهريب كيانات HTML (HTML Entities)
تهيئة سلسلة نصية كـ Slug
رموز حالة HTTP
صائد عناوين URL
صانع شظايا بحث نص URL
عجلة الألوان
محرر HTML مرئي
محلل وكيل المستخدم
محول CSS XPath
محول الألوان
محول بكسل REM
محول وحدات CSS
مدقق تباين الألوان
معلومات الجهاز
منظف HTML
منظف عناوين URL
مولد تدرج CSS
مولد صور SVG مؤقتة
مولد عنوان URL لـ UTM
مُجمِّل CSS
مُحسِّن HTML
مُصغّر HTML
HTML إلى Markdown
Markdown Lorem Ipsum
Markdown إلى DOCX
Markdown إلى HTML
Markdown إلى بيانات
tools.markdown-format-converter.name
تحويل Markdown إلى نص
تحويل ملفات epub إلى Markdown
لصق كعلامة Markdown
محرر Markdown
معاينة Markdown
مقارنة ماركداون
مولد جداول Markdown
مولد جدول المحتويات Markdown
مُحسِّن جدول Markdown
منشئ تعبيرات Cron
حاسبة الاستهلاك
التعرف الضوئي على الحروف في الرياضيات
حاسبة الإكراميات
حاسبة ثنائية
محلل رياضي
محول صيغ الرياضيات
مُصوِّر المنحنيات المثلثية/المعادلات
Docker Compose إلى Quadlets
Docker Compose إلى ملف .env
Docker compose إلى kubernetes
برنامج Traefik Docker Compose Maker
برنامج تنزيل صور Docker
تشغيل Docker إلى Kubernetes
تشغيل Docker إلى Quadlets
فحص Docker لتشغيل Docker
محول Docker Compose إلى Docker run
محول أوامر Docker run إلى Docker compose
محول تنسيق Docker Compose
ملصقات دوكر بانغولين
مولد التحكم في الوصول المستند إلى الأدوار (RBAC) في Kubernetes
مولد تسميات Dockerfile
مُحقق Docker Compose
تحويل HTML إلى PDF
تشفير PDF
تنسيق PDF Linearize/FastWeb
ضاغط PDF
فك تشفير وفتح ملفات PDF
مدقق تواقيع PDF
مستخرج صفحات PDF
مستخرج نصوص PDF
مُجمّع ملفات PDF
YAML إلى TOML
اندماج YAML
تجميل وتنسيق YAML
محول YAML إلى JSON
مُسطّح/غير مُسطّح YAML

ورقة الغش Nginx

تكوين Nginx والأوامر المفيدة

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