Use it to publish applications behind a single front end, or when proxied requests return 502/504 or wrong URLs.
Reverse Proxy
A reverse proxy (Nginx, Apache mod_proxy, HAProxy) accepts client requests and forwards them to backend servers, often terminating TLS, adding headers and balancing load.
1. Backend reachable from the proxy: curl -v http://<backend>:<port>.
2. 502 → backend down/refused or SELinux (ausearch -m avc -ts recent).
3. 504 → backend slow; check proxy timeouts.
4. Headers forwarded (Host, X-Forwarded-*)?
5. Test through the proxy with curl.
client → proxy (TLS terminated) → upstream selected → request forwarded with headers → backend response returned
For Web Services → Reverse Proxy, continue with the first unproven Topic check: Record exact frontend request and expected upstream URL, Host/SNI, headers and timeout behavior. If that boundary is healthy, advance to the adjacent check: Verify effective proxy route and resolve/test the upstream from the proxy host context. 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.
curl -I -H 'Host: app.example.com' http://127.0.0.1Verification & 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
client → frontend DNS/TCP/TLS/HTTP → proxy route → upstream name resolution → upstream TCP/TLS/HTTP → application → proxy response
Healthy evidence: frontend request reaches the expected proxy route, upstream destination and headers are correct, connection/TLS succeeds and application response returns intact
Step 2 Verification and output interpretation Verify boundary
Existing fast checks for this Topic. - Record exact frontend request and expected upstream URL, Host/SNI, headers and timeout behavior.
- Verify effective proxy route and resolve/test the upstream from the proxy host context.
- Correlate frontend and upstream logs/connection evidence for the same request.
- Change only the confirmed proxy/upstream cause, then retest through the real frontend path and directly where useful.
Verification chain. client → frontend DNS/TCP/TLS/HTTP → proxy route → upstream name resolution → upstream TCP/TLS/HTTP → application → proxy response
Step 3 Specialized verification Verify boundary
First show the client reaches the intended proxy virtual host, then test the upstream directly from the proxy host/namespace using equivalent protocol/TLS parameters. Correlate access/error logs and upstream timing/status. Inspect DNS resolution from the proxy context if upstream names are used. For header problems, capture what the upstream actually receives. A proxy-generated 502/504 localizes the failure differently from an upstream 5xx; verify which component generated the status.
Step 4 Commands Verify boundary
curl -I -H 'Host: app.example.com' http://127.0.0.1
nginx -T | grep proxy_pass
Step 5 Failure modes and next checks Narrow the fault
Suspicious evidence: frontend is healthy but upstream DNS/connect/TLS fails, Host or forwarded headers change application behavior, timeout/body limits differ, or a cached/proxy-generated response hides backend failure
Step 6 Special cases and limits Narrow the fault
Client TLS success shows only the front leg. Upstream TLS, DNS, routing and application readiness can fail independently. X-Forwarded-* headers are untrusted input unless sanitized at a trusted proxy boundary. A direct upstream test can succeed while proxy-specific Host/SNI/header policy still fails. Keep front listener, proxy routing/config, upstream transport/TLS and application response separate.
Step 7 Common mistakes Narrow the fault
- Not passing
X-Forwarded-For/Hostheaders to the backend.
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.
Pass the original host and client address (Host, X-Forwarded-For, X-Forwarded-Proto). On RHEL, SELinux blocks the proxy from connecting out unless setsebool -P httpd_can_network_connect 1. Tune timeouts for slow backends.
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
Reverse proxy health is confirmed only when both frontend and upstream legs succeed with the intended routing, headers, identity and application semantics.
In depth
Reverse proxies: forwarding requests to applications
A reverse proxy accepts client requests and forwards them to backend applications. The client sees one server, while TLS, caching, compression and load balancing happen at the proxy. The nginx proxy module documentation describes the behaviour that matters most:
proxy_passwith a URI part replaces the matching part of the request URI. Without one, the URI is passed on unchanged.- By default, nginx sets
Hostto$proxy_hostandConnection: close. The client's original Host isn't sent unless configured, and$hostis the recommended way. proxy_set_headerdirectives are inherited only if the current level defines none.$proxy_add_x_forwarded_forappends the client address to X-Forwarded-For.proxy_read_timeout(60 s) applies between two reads, not to the whole response.- Buffering is on by default.
- Since nginx 1.29.7, HTTP/1.1 is the default to the backend (before that, 1.0).
Apache's mod_proxy documentation adds the reverse-proxy rule for Apache: ProxyRequests should stay off. Open forward proxies are dangerous, and a reverse proxy with ProxyPass doesn't need it.
proxy_pass URI rules (nginx)
| Configuration | Request | Sent to the backend |
|---|---|---|
location /app/ { proxy_pass http://127.0.0.1:8080/; } | /app/users | /users |
location /app/ { proxy_pass http://127.0.0.1:8080; } | /app/users | /app/users |
location /api/ { proxy_pass http://127.0.0.1:8080/v2/; } | /api/users | /v2/users |
A complete reverse-proxy location
host$ cat /etc/nginx/conf.d/app.conf
upstream report_api {
server 127.0.0.1:8080;
server 127.0.0.1:8081 backup;
keepalive 16;
}
server {
listen 443 ssl;
http2 on;
server_name reports.example.net;
ssl_certificate /etc/ssl/certs/reports.fullchain.pem;
ssl_certificate_key /etc/ssl/private/reports.key;
location / {
proxy_pass http://report_api;
proxy_http_version 1.1;
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;
proxy_set_header Connection "";
proxy_read_timeout 120s;
}
}
host$ sudo nginx -t && sudo systemctl reload nginx
host$ curl -s -o /dev/null -w "%{http_code} %{time_total}\n" https://reports.example.net/health
200 0.041
host$ sudo tail -3 /var/log/nginx/error.log
Common reverse-proxy errors
| nginx response | Cause |
|---|---|
| 502 Bad Gateway | The backend refused or reset the connection; it's down, or on the wrong port |
| 504 Gateway Timeout | The backend didn't answer within proxy_read_timeout |
| Redirect loops, or http links | The backend doesn't know about TLS; send X-Forwarded-Proto |
| The application logs the proxy's IP for every client | It doesn't trust X-Forwarded-For from the proxy |
Connection "", combined with keepalive in the upstream, reuses backend connections instead of opening one per request. On SELinux systems, nginx also needs the boolean httpd_can_network_connect to reach the backend port.
Documented example, not captured output.
How it works at runtime
Reverse Proxy is part of Web Services → Reverse Proxy. A Linux reverse proxy terminates a client-facing request and creates a separate upstream request; both legs have independent DNS, TLS, timeout, header and health boundaries.
Topic-specific state model. A Linux reverse proxy terminates a client-facing request and creates a separate upstream request; both legs have independent DNS, TLS, timeout, header and health boundaries.
Interpretation rule. - Frontend HTTP success ≠ the upstream application was contacted.
- TCP reachability to an upstream ≠ correct TLS name, Host header or application route.
- A 502/504 from the proxy ≠ evidence the proxy itself is misconfigured.
- Direct backend success ≠ the proxied request carries equivalent headers, identity or path.
Specialized mechanics
A reverse proxy terminates a client connection and creates a separate upstream transaction. It can therefore change protocol version, source identity, Host and forwarding headers, TLS trust/SNI, buffering and timeout behavior between the two legs. Load balancing and connection reuse add state that clients do not see directly. Troubleshooting must treat client→proxy and proxy→upstream as distinct flows with a request-correlation key where possible. Health checks, upstream selection and retry policy can cause otherwise similar requests to reach different backends and produce different failure signatures.
Quick reference
Reverse proxy configuration (Nginx):
upstream app { server 127.0.0.1:8080; server 127.0.0.1:8081; keepalive 32; }
location / {
proxy_pass http://app;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Connection "";
proxy_read_timeout 60s;
}
location /ws/ { proxy_pass http://app; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection upgrade; }
On SELinux systems, Nginx/httpd connecting to upstream ports needs setsebool -P httpd_can_network_connect 1. 502 = upstream refused/crashed, 504 = upstream timed out.
Limits and how it fails
Primary failure point. Reverse proxy health is confirmed only when both frontend and upstream legs succeed with the intended routing, headers, identity and application semantics.
ReferenceConfiguration & state2 sections · depth on demand
Configuration, persistence and lifecycle
Distribution/platform context. Reverse Proxy owns proxy transition semantics; frontend TLS, upstream service health and network/DNS dependencies remain separately testable.
Specialized lifecycle
Define upstream scheme/address, Host handling, forwarding headers and timeout/body-size/buffering policy deliberately. When proxying HTTPS, configure upstream SNI and certificate verification according to the real trust model instead of globally disabling checks. Preserve client identity only through trusted header boundaries and ensure the upstream framework knows which proxies are trusted. Health checks and failover should match application semantics rather than merely TCP reachability.
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 → Reverse Proxy. 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: reverse-proxy upstream selection, headers, buffering and timeout boundaries. 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/http/ngx_http_proxy_module.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
Reverse Proxy operational reference
Topic-specific lookup boundaries, proof limits and next-step Evidence for Reverse Proxy.
| Lookup boundary | Topic-specific reference | Operational use |
|---|---|---|
| Scope / effective state | A Linux reverse proxy terminates a client-facing request and creates a separate upstream request; both legs have independent DNS, TLS, timeout, header and health boundaries. | 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 | client → frontend DNS/TCP/TLS/HTTP → proxy route → upstream name resolution → upstream TCP/TLS/HTTP → application → proxy response | Trace requested/configured state through effective state to the observed workload result. |
| Failure boundary | Reverse proxy health is proven only when both frontend and upstream legs succeed with the intended routing, headers, identity and application semantics. | 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: client → frontend DNS/TCP/TLS/HTTP → proxy route → upstream name resolution → upstream TCP/TLS/HTTP → application → proxy response | 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. Reverse proxy health is proven only when both frontend and upstream legs succeed with the intended routing, headers, identity and application semantics. | 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. |
Reverse Proxy · operational reference
Compact Linux state, persistence, verification and boundary reference for fast lookup.
| Reference boundary | Reverse Proxy |
|---|---|
| Topic path | Web Services → Reverse Proxy |
| Runtime state | A Linux reverse proxy terminates a client-facing request and creates a separate upstream request; both legs have independent DNS, TLS, timeout, header and health boundaries. |
| Fast checks | - Record exact frontend request and expected upstream URL, Host/SNI, headers and timeout behavior. - Verify effective proxy route and resolve/test the upstream from the proxy host context. - Correlate frontend and upstream logs/connection evidence for the same request. - Change only the proven proxy/upstream cause, then retest through the real frontend path and directly where useful. |
| Verification chain | client → frontend DNS/TCP/TLS/HTTP → proxy route → upstream name resolution → upstream TCP/TLS/HTTP → application → proxy response Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. |
| Failure boundary | Reverse proxy health is proven only when both frontend and upstream legs succeed with the intended routing, headers, identity and application semantics. 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. |
Reverse Proxy · specialized operational reference
Topic-specific Linux mechanics, lifecycle, proof path and failure-boundary lookup.
| Operational boundary | Topic-specific reference |
|---|---|
| Leg 1 | client → proxy listener/TLS/vhost |
| Leg 2 | proxy → upstream DNS/route/TLS/app |
| Headers | Host + forwarding identity are explicit trust boundary |
| Proof | Correlated request succeeds across both legs |