Use it to configure or troubleshoot Nginx sites and proxies.
Nginx
Nginx is an event-driven web server and reverse proxy, configured with server blocks (virtual hosts) and location blocks, commonly in /etc/nginx/nginx.conf, conf.d/ and sites-enabled/.
1. nginx -t — syntax ok?
2. nginx -T | grep -n server_name — which block handles the name?
3. Error log for upstream errors.
4. Upstream up? curl -v http://127.0.0.1:<port>.
5. systemctl reload nginx and test.
request → listen socket → server_name match → location → static file or proxy_pass → response
For Web Services → Nginx, continue with the first unproven Topic check: Pin effective config, listener, requested scheme/Host/path and expected upstream or document root. If that boundary is healthy, advance to the adjacent check: Validate and inspect the parsed configuration, process state and socket ownership. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.
Continue only after interpreting the current observation.Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
nginx config/includes → syntax/effective dump → master/workers → listen socket → server_name/SNI → location selection → file/proxy/upstream → response/log
Healthy evidence: effective config parses, master/workers run, intended listener and server_name/location are selected, upstream/static handling succeeds and logs match the client response
Step 2 Verification and output interpretation Verify boundary
Existing fast checks for this Topic. - Pin effective config, listener, requested scheme/Host/path and expected upstream or document root.
- Validate and inspect the parsed configuration, process state and socket ownership.
- Send the exact request while correlating access/error logs and upstream status or filesystem access.
- Make the smallest persistent change, reload, and repeat the original request plus one neighboring route.
Verification chain. nginx config/includes → syntax/effective dump → master/workers → listen socket → server_name/SNI → location selection → file/proxy/upstream → response/log
Step 3 Specialized verification Verify boundary
Validate syntax, inspect the effective expanded configuration when include ambiguity matters, then verify master/worker generations after reload. Test the exact listen address, hostname/SNI and request path, capturing status, headers and logs. If the response is wrong, localize server selection before location/upstream behavior. A successful config test shows parsing; a successful reload shows Nginx accepted it; only the client request shows the intended virtual host/path behavior.
Step 4 Commands Verify boundary
nginx -t
nginx -T | head
tail /var/log/nginx/error.log
Step 5 Failure modes and next checks Narrow the fault
Suspicious evidence: syntax passes but another server block/location wins, old config remains loaded, upstream resolution/connectivity fails, permissions block static content, or client path differs from local testing
Step 6 Special cases and limits Narrow the fault
Nginx can be healthy while the upstream application is down, and an HTTP error may be generated by Nginx, an upstream or another proxy. A 200 response on localhost/default Host does not show the public virtual host. TLS certificate selection can differ by SNI. Reload success does not show every request uses only new workers instantly. Keep listener/virtual-host selection, request routing, upstream and application result separate.
Step 7 Common mistakes Narrow the fault
- Missing
server_name, so the default server answers.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
nginx -t before every reload. nginx -T prints the full merged config. The first matching server block for a port is the default — unknown names land there. 502 means the upstream refused or crashed; 504 means it timed out.
systemctl status nginx|apache2|httpd— web server statenginx -t / apachectl configtest— configuration testss -ltnp | grep -E ':80|:443'— listening portscurl -vI https://<name>— response, headers and TLStail -f /var/log/nginx/error.log— error log (or apache2/httpd)
ReferenceImportant terms & boundaries6 sections · depth on demand
What this shows and what it does not
Nginx is resolved only when the intended server and location handle the exact client request and any upstream returns the expected application result.
In depth
nginx: worker model, configuration and TLS defaults
nginx is an event-driven web server and reverse proxy. A master process reads the configuration, and a small number of worker processes handle all connections. The nginx guide to HTTPS servers documents several defaults worth knowing:
ssl_protocols TLSv1.2 TLSv1.3andssl_ciphers HIGH:!aNULL:!MD5are the defaults, so they normally don't need to be set.- The certificate file must list the server certificate first, then the intermediates. Otherwise nginx refuses to start with "key values mismatch".
- The private key must be readable by the master process.
- One megabyte of shared session cache holds about 4,000 sessions, and the default session timeout is 5 minutes.
worker_processesshould be at least the number of CPU cores, because TLS handshakes are CPU-intensive.- HTTP and HTTPS can share one server block, using
listen 443 ssl. The oldssl ondirective was removed in 1.25.1.
Configuration structure
| Context | Holds |
|---|---|
| main | worker_processes, user, error_log |
events | worker_connections |
http | Shared settings: logs, gzip, TLS session cache, include of sites |
server | One site: listen, server_name, certificates |
location | Handling for matching URIs: root, proxy_pass, try_files |
Layout by distribution
| Debian / Ubuntu | RHEL family / upstream packages | |
|---|---|---|
| Sites | sites-available/ + symlink in sites-enabled/ | conf.d/*.conf |
| Web root default | /var/www/html | /usr/share/nginx/html |
host$ cat /etc/nginx/conf.d/www.conf
server {
listen 80;
listen 443 ssl;
http2 on;
server_name www.example.net example.net;
ssl_certificate /etc/ssl/certs/www.example.net.fullchain.pem;
ssl_certificate_key /etc/ssl/private/www.example.net.key;
root /srv/www/example;
location / { try_files $uri $uri/ =404; }
}
host$ sudo nginx -t && sudo systemctl reload nginx
host$ ps -o pid,user,cmd -C nginx
PID USER CMD
1203 root nginx: master process /usr/sbin/nginx
1204 www-data nginx: worker process
host$ nginx -V 2>&1 | grep -o "TLS SNI support enabled"
host$ curl -sI https://www.example.net | head -1
Reload is graceful
nginx -s reload, or systemctl reload, starts new workers with the new configuration, and lets old workers finish their current requests. A configuration that fails nginx -t is never applied, so always test first. The running configuration then stays in place.
Documented example, not captured output.
How it works at runtime
Nginx is part of Web Services → Nginx. Nginx on Linux is verified from parsed configuration and master/worker runtime state through listen/server_name selection, location processing, TLS, static-file or upstream handling and the client-visible response.
Topic-specific state model. Nginx on Linux is verified from parsed configuration and master/worker runtime state through listen/server_name selection, location processing, TLS, static-file or upstream handling and the client-visible response.
Interpretation rule. - nginx -t success ≠ the intended server block is selected.
- Nginx running ≠ an upstream application is healthy.
- A 200 response ≠ it came from the intended location or backend.
- Reload accepted ≠ every worker immediately reflects a semantically correct configuration.
Specialized mechanics
Nginx uses a master process to load configuration and manage worker processes that accept connections and execute request-processing phases. Server block selection depends on listen address/port and host/SNI, while location selection determines content/proxy behavior within the chosen server. A graceful reload causes the master to parse new configuration, start new workers and retire old workers, so old and new worker generations can briefly coexist. Directive inheritance is context-specific, so moving a directive between http, server and location scopes can materially change the effective request path.
Quick reference
Nginx essentials:
nginx -t && systemctl reload nginx
nginx -T | less # full effective config
/etc/nginx/nginx.conf, /etc/nginx/conf.d/*.conf, (Debian) sites-enabled/
Key directives:
| Directive | Note |
|---|---|
worker_processes auto; | One per CPU |
worker_connections 4096; | Per worker |
server_name | Host matching, default_server for unmatched |
location | Prefix, exact (=), regex (~) matching order |
client_max_body_size | Upload limit (413 errors) |
proxy_read_timeout | Upstream timeouts (504) |
Reload is graceful — old workers finish requests; restart drops connections.
Limits and how it fails
Primary failure point. Nginx is resolved only when the intended server and location handle the exact client request and any upstream returns the expected application result.
Apache/Nginx config syntax success is not application health.
ReferenceConfiguration & state2 sections · depth on demand
Configuration, persistence and lifecycle
Validate Apache/Nginx configuration before reload and understand virtual-host/SNI/default-server selection.
Distribution/platform context. Nginx owns server/location and proxy behavior; Certificates & TLS, DNS, Firewall and application upstreams own their separate boundaries.
Specialized lifecycle
Keep configuration modular but make include order and ownership explicit. Run the configuration test before reload and use a graceful reload for supported changes. Define default servers intentionally so unmatched Host/SNI requests do not land in a sensitive virtual host. For TLS, coordinate certificate/key paths and reload timing. For reverse proxying, treat upstream, headers and timeout policy as application contract rather than relying on defaults. Avoid editing generated configs when a control panel/orchestrator owns them.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Web Services → Nginx. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://nginx.org/en/docs/ · confidence 94%Authoritative Linux project/vendor documentation reviewed for bounded reference claims: configuration structure, reload behavior, server selection and request handling. Documentation-based technical verification only; not lab or production-runtime proof. The schema vendor_doc method is used for authoritative project/vendor documentation; deployment applicability remains separate evidence.
Basis: https://nginx.org/en/docs/beginners_guide.html · confidence 93%What changed and what may be affected
Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
Nginx operational reference
Topic-specific lookup boundaries, proof limits and next-step Evidence for Nginx.
| Lookup boundary | Topic-specific reference | Operational use |
|---|---|---|
| Scope / effective state | Nginx on Linux is verified from parsed configuration and master/worker runtime state through listen/server_name selection, location processing, TLS, static-file or upstream handling and the client-visible response. | Establish exactly what this Topic owns before crossing into another subsystem. |
| Fast verification | Pin exact client/server + time + request/file operation → identify authoritative configuration → read back effective service/listener/session state → trace protocol selection/auth/identity → verify backend/upstream boundary → correlate logs → make smallest persistent change → repeat original workload + regression check. | Use the shortest evidence path first; a fast check is a boundary test, not blanket proof. |
| Verification chain | nginx config/includes → syntax/effective dump → master/workers → listen socket → server_name/SNI → location selection → file/proxy/upstream → response/log | Trace requested/configured state through effective state to the observed workload result. |
| Failure boundary | Nginx closes only when the intended server and location handle the exact client request and any upstream returns the expected application result. | Stop broad troubleshooting at the first boundary that is not supported by evidence. |
| Positive evidence | Correlated Linux web/file-service evidence can establish this proof path: nginx config/includes → syntax/effective dump → master/workers → listen socket → server_name/SNI → location selection → file/proxy/upstream → response/log | Use this observation only for the specific claim it actually supports. |
| Evidence limit | It does not independently prove unobserved clients, names, identities, routes, sessions, backends or time periods. Nginx closes only when the intended server and location handle the exact client request and any upstream returns the expected application result. | Do not promote a local success signal into end-to-end or adjacent-dependency proof. |
| Next troubleshooting check | Continue from the first unproven service boundary, capture adjacent effective state and protocol/application evidence, make only the demonstrated persistent change, then repeat the original client workload plus a regression check. | Continue to the next unresolved boundary while preserving the original test condition. |
Nginx · operational reference
Compact Linux state, persistence, verification and boundary reference for fast lookup.
| Reference boundary | Nginx |
|---|---|
| Topic path | Web Services → Nginx |
| Runtime state | Nginx on Linux is verified from parsed configuration and master/worker runtime state through listen/server_name selection, location processing, TLS, static-file or upstream handling and the client-visible response. |
| Fast checks | - Pin effective config, listener, requested scheme/Host/path and expected upstream or document root. - Validate and inspect the parsed configuration, process state and socket ownership. - Send the exact request while correlating access/error logs and upstream status or filesystem access. - Make the smallest persistent change, reload, and repeat the original request plus one neighboring route. |
| Verification chain | nginx config/includes → syntax/effective dump → master/workers → listen socket → server_name/SNI → location selection → file/proxy/upstream → response/log Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. |
| Failure boundary | Nginx closes only when the intended server and location handle the exact client request and any upstream returns the expected application result. Boundary chain: unit config/drop-ins → dependency/order/condition → exec/process → readiness/active state → owned socket/file/device → dependent client/workload. |
| Persistence rule | Prove which configuration source owns the state, then prove that the running consumer loaded or generated the intended state. |
Nginx · specialized operational reference
Topic-specific Linux mechanics, lifecycle, proof path and failure-boundary lookup.
| Operational boundary | Topic-specific reference |
|---|---|
| Selection | listen → server_name/SNI → location |
| Lifecycle | Master parses; graceful reload rotates workers |
| Proof | Exact host/path client request + correlated access/error logs |
| Boundary | Frontend health separate from upstream/application |