Pcornel
Browse topics
Options
Recent
Favorites
Web Infrastructure · Technical reference

Reverse Proxy

Direct answer

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.

When to use this

Use it to publish applications behind a single front end, or when proxied requests return 502/504 or wrong URLs.

First 30 seconds

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.

Operational verification

client → proxy (TLS terminated) → upstream selected → request forwarded with headers → backend response returned

Evidence · next step

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
Platform / version applicability
linux
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformlinux
Key commandcurl -I -H 'Host: app.example.com' http://127.0.0.1
Scope / prerequisiteUse it to publish applications behind a single front end, or when proxied requests return 502/504 or wrong URLs.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

7 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

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/Host headers to the backend.
Evidence references

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.

observation · 1
Key points

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.

Key checks
  • systemctl status nginx|apache2|httpd — web server state
  • nginx -t / apachectl configtest — configuration test
  • ss -ltnp | grep -E ':80|:443' — listening ports
  • curl -vI https://<name> — response, headers and TLS
  • tail -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_pass with a URI part replaces the matching part of the request URI. Without one, the URI is passed on unchanged.
  • By default, nginx sets Host to $proxy_host and Connection: close. The client's original Host isn't sent unless configured, and $host is the recommended way.
  • proxy_set_header directives are inherited only if the current level defines none.
  • $proxy_add_x_forwarded_for appends 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)

ConfigurationRequestSent 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 responseCause
502 Bad GatewayThe backend refused or reset the connection; it's down, or on the wrong port
504 Gateway TimeoutThe backend didn't answer within proxy_read_timeout
Redirect loops, or http linksThe backend doesn't know about TLS; send X-Forwarded-Proto
The application logs the proxy's IP for every clientIt 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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

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
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor doclinux current

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%
2026-09-13 · vendor docNGINX current

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%
Technical changelog & impact

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.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Terminology layer

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.

Aliases that resolve here
reverse proxylinux reverse proxynginx apache proxy
Embedded reference data

Quick lookup tables

Reverse Proxy operational reference

Topic-specific lookup boundaries, proof limits and next-step Evidence for Reverse Proxy.

Lookup boundaryTopic-specific referenceOperational use
Scope / effective stateA 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 verificationPin 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 chainclient → frontend DNS/TCP/TLS/HTTP → proxy route → upstream name resolution → upstream TCP/TLS/HTTP → application → proxy responseTrace requested/configured state through effective state to the observed workload result.
Failure boundaryReverse 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 evidenceCorrelated 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 responseUse this observation only for the specific claim it actually supports.
Evidence limitIt 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 checkContinue 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 boundaryReverse Proxy
Topic pathWeb Services → Reverse Proxy
Runtime stateA 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 chainclient → 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 boundaryReverse 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 ruleProve 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 boundaryTopic-specific reference
Leg 1client → proxy listener/TLS/vhost
Leg 2proxy → upstream DNS/route/TLS/app
HeadersHost + forwarding identity are explicit trust boundary
ProofCorrelated request succeeds across both legs
Confirmation

Confirm action

Continue?