Join our Newsletter — 33% off our NHI Course
Home› Guides› Proxies and Forward vs Reverse Proxy Security Guide:…
Guide Network Security

Proxies and Forward vs Reverse Proxy Security Guide: Roles, Risks and Hardening

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 26 October 2026 17 min read
On this page

Proxies sit in the path of almost every web request an organisation makes or receives, and a misconfigured one quietly becomes an open relay, an SSRF launch point or a source of forged client identity. A forward proxy acts for your users and workloads going out; a reverse proxy acts for your servers taking traffic in. They share software (NGINX, Apache httpd, HAProxy, Squid, Envoy) but have opposite trust models, and most proxy incidents come from confusing the two. This guide explains the roles, the specific risks of each, how to harden and log them, and how to roll changes out safely. It is written for network, platform and application security engineers who own or depend on proxy tiers, and it goes deeper than the Network Security Guide on this one component.

Key takeaways

  • Direction defines the trust model. A forward proxy must restrict who can use it and where they can go; a reverse proxy must restrict which backends it reaches and which request headers it believes.
  • Forwarding headers are claims, not facts. RFC 7239 states that the Forwarded header is not authoritative and can be changed by any node, including the client, so trust only values added by proxies you operate.
  • The open proxy is still the classic failure. Apache's own documentation warns that open proxy servers are dangerous to your network and to the Internet at large; the same applies to unrestricted CONNECT tunnels.
  • A reverse proxy is a privileged workload. It holds TLS private keys, routes to internal hosts and often carries a cloud role, so SSRF or a memory leak in it exposes far more than one application.
  • Logs at the proxy are your best web telemetry. Done well, they record the true client, the identity, the destination and the TLS details for every request, which is what detection for T1090 and T1071.001 depends on.

Forward, reverse and transparent proxies compared

RFC 9110 defines a proxy as an intermediary chosen by the client, usually through local configuration, and a gateway (reverse proxy) as an intermediary that acts as the origin server for the outbound connection and forwards requests inbound to one or more other servers. A tunnel is a blind relay that does not change messages, which is what an HTTP CONNECT session becomes once established.

AspectForward proxyReverse proxy (gateway)Transparent / intercepting proxy
Acts forClients: users, servers, workloads, agents going outboundOrigin servers receiving inbound trafficClients, without client configuration (traffic is redirected by the network)
Who knows it existsClient (PAC file, WPAD, environment variables such as HTTPS_PROXY)Server operator; the client believes it is the originNetwork operator only
Main security jobsEgress control, URL and category filtering, malware scanning, data loss checks, user attributionTLS termination, routing, WAF, rate limiting, hiding backend topology, authentication offloadEgress control where clients cannot be configured (guest, IoT)
Typical abuseOpen relay, CONNECT tunnelling to arbitrary ports, bypass by direct egressHeader spoofing, Host header routing SSRF, request smuggling, cache poisoning, exposed admin endpointsBreaks certificate pinning and mutual TLS; hard to attribute users
Access control focusWho may use it, which destinations and portsWhich hostnames and paths are published, which backends may be reachedWhich networks are redirected, what is bypassed
Common softwareSquid, secure web gateway services, Apache with ProxyRequests OnNGINX, HAProxy, Envoy, Apache with ProxyPass, cloud application gatewaysSquid intercept mode, firewall web proxies

Cloud and SASE products blur these lines: a secure web gateway is a managed forward proxy, and a CDN or application load balancer is a managed reverse proxy. The risks below still apply; only the configuration surface changes. See the Secure Web Gateway and Web Filtering Guide for the filtering policy side and the Load Balancer Security Guide for the L4/L7 balancing tier.

Threats by proxy role

ThreatRole affectedWhat happensPrimary controlReference
Open proxy abuseForwardOutsiders relay traffic through you, hiding their origin and attributing abuse to your IP spaceBind to internal interfaces, authenticate users, deny by defaultATT&CK T1090.002 External Proxy
Arbitrary CONNECT tunnelsForwardCONNECT to SSH, SMTP or custom ports creates an unfiltered tunnel outAllow CONNECT only to an SSL_ports list (usually 443)T1572 Protocol Tunneling
C2 over web protocolsForwardMalware beacons through the sanctioned proxy, blending with normal trafficCategory filtering, newly registered domain blocking, beacon analyticsT1071.001 Web Protocols, T1090.004 Domain Fronting
Internal proxy pivotingBothAn attacker on one host relays traffic into segments it cannot reach directlySegmentation, deny proxy software on endpoints, monitor east-west HTTPT1090.001 Internal Proxy
Client IP spoofingReverseClient sends its own X-Forwarded-For; app trusts it for rate limits, allowlists or auditOverwrite or sanitise at the edge; trust only known proxy addressesRFC 7239 s8
Host header and routing SSRFReverseProxy routes on an attacker-supplied Host or X-Forwarded-Host to internal hostsExplicit server_name / virtual host allowlist, default deny catch-allT1190; PortSwigger Host header research
Request smuggling and desyncReverseFront end and backend parse message length differently; requests cross between usersNormalise or reject ambiguous requests, HTTP/2 end to end where possibleSee the HTTP Request Smuggling Guide
Adversary in the middleBothProxy re-encrypts with weak or no backend TLS; internal traffic readableTLS or mTLS to backends with certificate validationT1557; SP 800-53 SC-8
Exploited proxy softwareBothUnpatched proxy is the internet-facing applicationPatch to KEV deadlines, minimal modules, no exposed admin interfacesCVE-2021-41773 (Apache httpd path traversal, in CISA KEV)

For the detail behind two of these rows, see the HTTP Request Smuggling Guide and the Web Cache Poisoning and Cache Deception Guide.

Hardening a forward proxy

The forward proxy is the control point for outbound traffic, which makes it valuable only if traffic cannot go around it. NIST SP 800-53 SC-7(8) "Route Traffic to Authenticated Proxy Servers" captures the intent: outbound traffic of defined types goes through an authenticated proxy at managed interfaces.

  • Close the bypass first: block direct outbound TCP 80 and 443 at the firewall for every network that should use the proxy, and allow it only from the proxy's own addresses. Without this, filtering is advisory. Treat DNS over HTTPS to public resolvers the same way.
  • Restrict who can use it: listen only on internal interfaces, and limit source networks with ACLs. Apache httpd's mod_proxy documentation says it is essential to secure the server so only authorised clients can use a forward proxy before activating one, using <Proxy "*"> blocks with Require rules.
  • Restrict ports and methods: in Squid, keep http_access deny !Safe_ports and http_access deny CONNECT !SSL_ports near the top of the configuration. Squid's guidance warns never to add port 25 to Safe_ports, which would turn the proxy into a mail relay.
  • Mind rule order: Squid evaluates http_access top to bottom. An allow for a custom port placed above deny !localnet exposes the proxy publicly. Combine conditions (http_access allow localnet mycoolapp) rather than adding broad allows.
  • Protect management functions: the Squid cache manager can show configuration, logged-in users and network layout, and can shut the service down. Keep the default http_access allow localhost manager followed by http_access deny manager at the top, or narrow it to a management network.
  • Authenticate users and workloads: use Kerberos or the identity provider for people, and per-workload credentials or source identity for servers, so every log line names a principal. A shared proxy account used by many servers removes attribution.
  • Filter destinations by policy: block uncategorised and newly registered domains, raw IP destinations and known anonymiser networks; allow only required SaaS for server networks rather than the whole web.
  • Decide on TLS inspection explicitly: CONNECT tunnels are opaque unless you decrypt. Decrypt by category with clear exemptions (health, banking, pinned applications) and a privacy assessment. See the TLS Inspection Guide.

Hardening a reverse proxy

Apache's documentation notes that a reverse proxy configured with ProxyPass and ProxyRequests Off is safer because clients can only reach hosts you have explicitly configured. That is the core design rule: the reverse proxy should publish a fixed, reviewed map of hostname and path to backend, and nothing else.

Routing and exposure

  • Never enable forward proxying on a reverse proxy: ProxyRequests Off in Apache; in NGINX, never build proxy_pass targets from request variables such as $host or $arg_url without a fixed allowlist map.
  • Default deny virtual host: add a catch-all server block that rejects unknown Host values (for example returning 444 in NGINX or a static 421/404) so requests for internal names cannot be routed by guessing. PortSwigger's Host header research recommends forwarding only to allowlisted domains and not hosting internal-only virtual hosts on the same server as public content.
  • Disable override headers you do not need: do not let backends honour X-Forwarded-Host or X-Original-URL from clients. Strip them at the edge and set them yourself.
  • Keep admin paths off the public listener: status pages (stub_status, HAProxy stats, Envoy admin on its own port) should bind to localhost or a management network only.

Headers and client identity

  • Edge proxy overwrites, inner proxies append: the first proxy you control should replace any client-supplied X-Forwarded-For, X-Real-IP and Forwarded values. RFC 7239 is explicit that these values can be altered by any node, including the client, and that addresses added before the first trusted proxy cannot be verified.
  • Trust by address, not by header: NGINX's realip module uses the header only when the connection comes from an address listed in set_real_ip_from. With real_ip_recursive on, it takes the last address in the chain that is not trusted, which is the correct client when every hop is listed; with it off, it takes the last address, which is often your own proxy.
  • Prefer the PROXY protocol for TCP hops: when a layer 4 balancer sits in front, pass the client address in the PROXY protocol header and accept it only on listeners reachable solely from that balancer, because a listener that accepts it from anyone lets clients forge their address.
  • Avoid leaking topology: RFC 7239 recommends obfuscated node identifiers, warns against copying the header into responses and flags TRACE as a way to echo it back. Disable TRACE, remove Server and Via detail where it reveals internal names, and strip X-Powered-By from backend responses. See the Security Headers Guide for response headers to add.
  • Treat client IP as personal data: RFC 7239 highlights that client addresses can identify a user and location, so keep logging retention and access aligned with your privacy policy.

Protocol handling and TLS

  • Reject ambiguous requests: requests carrying both Content-Length and Transfer-Encoding, duplicate Content-Length, or invalid header characters should be rejected at the edge, not normalised differently by each hop.
  • Set sane limits: header size, body size, request rate and timeouts (for example client_max_body_size, large_client_header_buffers, proxy_read_timeout in NGINX) bound the cost of slow and large request attacks.
  • Re-encrypt to backends and validate: enable proxy_ssl_verify on with a trusted CA and proxy_ssl_name, or mutual TLS where backends must know which proxy is calling. Plain HTTP across a flat internal network is an adversary-in-the-middle opportunity (T1557). See the mTLS Guide.
  • Limit egress from the proxy itself: a reverse proxy should reach only its backends. Block access to cloud metadata endpoints (169.254.169.254) unless needed and require IMDSv2 on AWS, so an SSRF in the proxy or WAF tier cannot fetch role credentials.

Where identity fits

Proxies are full of non-human identities, and they are often the least governed. A reverse proxy holds private keys for every hostname it terminates, frequently runs with a cloud role, and may carry client certificates or API keys to call backends. A forward proxy often has a shared service account in the directory for Kerberos, plus credentials for upstream filtering or threat intelligence services.

  • Scope the proxy's cloud role to what it does: the Capital One breach is the reference case: SSRF through a misconfigured WAF fetched the WAF's own role credentials, and that role could list and read S3 buckets it never needed.
  • Treat sessions issued at the proxy as credentials: when a gateway handles authentication, its session cookies are bearer tokens. In CitrixBleed a memory leak on the NetScaler gateway returned valid session cookies that bypassed MFA, and patching did not revoke the stolen ones.
  • Rotate and inventory keys and certificates: keep TLS keys in an HSM or secrets manager where the platform allows, and track expiry and owners. See the Machine Identity, PKI and Certificate Lifecycle Guide.
  • Give each workload its own proxy credential: per-workload identity on the forward proxy makes egress policy and investigation possible. See the Service Account Security Guide.

Choosing a design

  • Explicit vs transparent forward proxy: explicit (PAC, WPAD or environment variables) gives clean user authentication and CONNECT visibility; transparent suits devices you cannot configure but loses user identity and breaks pinned or mutually authenticated applications. Most organisations run explicit for managed endpoints and servers, transparent only for guest and IoT segments.
  • On-premises proxy vs cloud secure web gateway: a cloud gateway covers remote users without backhaul and is patched by the provider; an on-premises proxy keeps server egress and decrypted content inside your boundary. Many run both: cloud for users, local for data centre and build servers. See the SASE and SSE Guide.
  • Self-managed reverse proxy vs managed gateway or CDN: self-managed gives full control of headers and routing and suits complex internal estates; managed services remove patching of an internet-facing appliance and add DDoS capacity, at the cost of a provider in your TLS path.
  • One tier or two: a single reverse proxy is simpler to reason about; a CDN plus regional proxy plus service mesh adds parsing differences between hops, so test smuggling and header trust across the whole chain.
  • Small organisations: use a managed gateway for users, a single well-maintained reverse proxy or cloud application gateway for public apps, and spend effort on blocking direct egress and on logging, which give most of the value.
  • Large organisations: standardise proxy configuration as code, publish an approved header contract (which headers the edge sets, which backends may trust), and run conformance tests on every change.

Implementation: a phased rollout

  1. Inventory: list every proxy, its role, listeners, upstreams, certificates, credentials and owner, including sidecars and ingress controllers. Scan your public ranges for open proxy behaviour and exposed admin ports.
  2. Baseline configuration: write a standard for each role covering the controls above, stored as code, and diff every existing proxy against it.
  3. Logging first: before tightening, enable full access logs (client, authenticated user, method, host, path, status, bytes, upstream, TLS version and SNI) and ship them to the SIEM, so you can see what tightening will break.
  4. Forward proxy tightening in rings: enable authentication and port restrictions in monitor or log-only mode where the product supports it, then enforce for an IT pilot, then by business unit. Block direct egress per network segment only once its traffic is seen through the proxy.
  5. Reverse proxy header contract: deploy edge sanitisation of forwarding headers and the default-deny virtual host to a staging environment, run smuggling and Host header tests, then roll out one hostname at a time.
  6. Backend TLS: introduce certificate validation to backends per service, with an alert on handshake failures, before switching off plaintext listeners.
  7. Rollback: keep the previous configuration version deployable in one step, use canary instances behind the balancer, and define the error-rate threshold that triggers rollback before each change.

Detection and measurement

Proxy logs underpin detection of web-based command and control and of proxy abuse. Useful detections include long-lived CONNECT sessions to rare destinations, regular beacon intervals to one domain, requests to raw IP addresses, CONNECT attempts to non-443 ports (blocked or not), user agents that do not match the endpoint's managed software, unknown Host values hitting the default virtual host, and requests carrying both Content-Length and Transfer-Encoding. On endpoints, alert on new local proxy listeners and on changes to system proxy settings, which can indicate T1090.001 internal proxy setup.

MetricWhat it showsTarget
Share of outbound web traffic that passes through the proxyWhether the bypass is closedClose to 100% for managed networks
Proxy log lines with an authenticated principalAttribution qualityAbove 95% for user networks
Public proxy listeners failing the open-proxy and admin-port scanExposureZero
Reverse proxies passing the header contract and smuggling testsHeader trust and parsing consistencyAll, re-tested on each release
Days to patch a proxy vulnerability listed in CISA KEVExposure window on internet-facing softwareWithin the KEV due date or your stricter SLA
Backend connections with verified TLSProtection of the proxy-to-origin hopRising to 100% of sensitive services

Common failure patterns

  • Forward proxying left on a reverse proxy: a ProxyRequests On line copied from an example turns a web server into an open relay that scanners find within days.
  • Trusting the leftmost X-Forwarded-For: rate limits, IP allowlists and audit logs keyed on a client-supplied value let attackers impersonate any address, including internal ones that bypass checks.
  • Filtering without blocking direct egress: the proxy shows a clean picture while malware and shadow tools leave directly on 443.
  • Overprivileged proxy and WAF roles: an SSRF in the edge tier becomes a data breach when the instance role can read storage, as in the Capital One breach.
  • Patching without session revocation: after a gateway memory disclosure such as CitrixBleed, stolen session tokens keep working until sessions are killed.
  • Plain HTTP behind TLS termination: the padlock covers only the first hop, while credentials and tokens cross the internal network unencrypted.

Framework mapping

FrameworkReferenceHow it applies to proxies
NIST CSF 2.0PR.IR-01, PR.DS-02, PR.PS-01, DE.CM-01Network access protection, data in transit, configuration management, network monitoring
NIST SP 800-53 Rev. 5SC-7, SC-7(8), SC-8, SC-23, CM-7, AU-2, AU-12, SI-4Boundary protection, authenticated proxies, transmission protection, session authenticity, least functionality, logging and monitoring
CIS Controls v8.19.3, 13.10Network-based URL filters; application layer filtering
ISO/IEC 27001:2022 Annex AA.8.20, A.8.22, A.8.23, A.8.24, A.8.15Networks security, segregation, web filtering, cryptography, logging
MITRE ATT&CK v20T1090 (.001 to .004), T1572, T1071.001, T1190, T1557Proxy and tunnelling abuse, web C2, exploitation of the proxy, interception

Practitioner checklist

  • Inventory every forward, reverse and transparent proxy with owner, listeners, upstreams, certificates and credentials.
  • Block direct outbound web traffic from networks that should use the forward proxy, and measure the share that goes through it.
  • Restrict forward proxy use to authenticated internal clients, and allow CONNECT only to an approved port list.
  • Confirm no reverse proxy has forward proxying enabled, and add a default-deny virtual host for unknown Host values.
  • Overwrite client-supplied forwarding headers at the edge and trust them downstream only from listed proxy addresses.
  • Bind admin and status interfaces to management networks and scan public ranges for exposure.
  • Re-encrypt and validate TLS to backends, and block proxy access to cloud metadata endpoints.
  • Scope proxy and WAF cloud roles to what they need, and rotate keys, certificates and service account credentials.
  • Ship full proxy logs to the SIEM with detections for beacons, odd CONNECT ports and ambiguous requests.
  • Patch proxy software to CISA KEV deadlines and revoke sessions after any memory disclosure.

Standards and references

Related NHI Mgmt Group resources: Network Security Guide · Load Balancer Security Guide · Secure Web Gateway and Web Filtering Guide · SSRF Prevention Guide · Web Application Firewall Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 26 October 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick the PDF box to continue.