ipdetecto.com logo
ipdetecto.com
My IPSpeed
Knowledge Hub
HomeKnowledge HubNginx Reverse Proxy Configuration
© 2026 ipdetecto.com
support@ipdetecto.comAboutContactPrivacyTermsllms.txt
Network Administration
5 MIN READ
Apr 19, 2026

How to Configure Nginx Reverse Proxy

proxy_pass URI rules, buffering, WebSocket upgrades, and trusted X-Forwarded-* headers behind TLS edges.

A reverse proxy terminates client connections and forwards requests to application servers. proxy_pass defines the upstream URL; a trailing slash alters URI rewriting. Tune proxy_buffering for large downloads versus streaming responses. WebSockets need Upgrade and Connection headers. Behind another proxy or CDN, restore the client IP with real_ip only for trusted networks.

ScenarioDirectivePitfall
Strip or keep URI prefixproxy_pass with or without trailing /Unexpected path rewriting
SSE or long pollproxy_buffering offHigher memory if misapplied globally
Client IP for logsset_real_ip_fromSpoofing if trusts are too wide

Related

X-Forwarded-For, nginx SSL, nginx configuration, performance tuning

Frequently Asked Questions

Q.Why does a trailing slash on proxy_pass change behavior?

It controls whether nginx replaces the matched location prefix when building the upstream URI—test both forms against your backend paths.

Q.When should proxy_buffering be disabled?

For streaming, SSE, or long-polling where buffering adds latency or breaks incremental delivery.

Q.How do I proxy WebSockets through nginx?

Pass Upgrade and Connection headers and map the Upgrade variable—often via map on $http_upgrade—so the handshake reaches the backend.

Q.How do I safely restore the real client IP?

List only trusted proxy subnets with set_real_ip_from, then set real_ip_header to the header your edge uses.

Q.What causes upstream timed out errors?

Slow backends, DNS stalls for variable upstreams, or timeouts smaller than backend processing—raise proxy_read_timeout thoughtfully.

Q.Should I use HTTP/1.1 to upstreams?

Usually yes for keepalive and modern backends; pair with clearing or setting Connection per your upstream requirements.

Q.Which X-Forwarded-* headers should I set?

Commonly X-Forwarded-For, X-Forwarded-Proto, and Host—match what your application framework expects and strip duplicates at the edge.

Q.Why configure a resolver for some proxy_pass setups?

Variables in proxy_pass defer resolution at request time; resolver supplies DNS for those dynamic upstream names.
TOPICS & TAGS
proxy_passnginx reverse proxyX-Forwarded-For