Reverse Proxy vs Forward Proxy: Where Localhost Tunnels Fit

Run ssh -p 443 -R0:localhost:3000 free.pinggy.io on a laptop behind carrier-grade NAT, and a public HTTPS URL starts serving whatever listens on port 3000. You didn’t change a router rule or open an inbound port. The command dialled out, the way a client behind a forward proxy does, but the endpoint it created accepts requests on behalf of a server. That’s a reverse proxy’s job.
That overlap is why the reverse proxy vs forward proxy question confuses people who work with tunnels. The two terms describe which side of the conversation the proxy represents. They say nothing about who opened the TCP connection, and a localhost tunnel separates those two things on purpose.
Summary
- A forward proxy acts for the client. The client is configured to use it, and over HTTPS it only relays encrypted bytes through
CONNECT, so it can’t add headers. - A reverse proxy acts for the server. DNS points at it, it terminates TLS, and it tells the backend who the visitor was through
X-Forwarded-FororForwarded. - A localhost tunnel is a reverse proxy whose backend dials out to the edge, so no inbound port is needed. The app sees
127.0.0.1unless it reads the forwarded headers. - To test a tunnelled app from another country, send a request through a forward proxy with an exit IP there and compare
X-Forwarded-Forin the Pinggy web debugger.
Forward proxies are chosen by the client
A forward proxy acts for the client. RFC 9110 defines a proxy as “a message-forwarding agent that is chosen by the client”, and chosen carries the meaning: the client is configured to use it through curl -x, the HTTPS_PROXY environment variable, a browser setting or a PAC file. The destination server sees the proxy’s exit address as the source.
Squid on port 3128 is the classic self-hosted example. The quickest one is ssh -D 1080 user@vps, which turns any SSH server into a SOCKS5 forward proxy. Commercial proxy providers sell the same function as a service, with exit IPs in the countries you pick. Open-source nginx couldn’t answer a CONNECT request without a third-party patch untill version 1.31 added ngx_http_tunnel_module.
Forward proxies read HTTP but only relay HTTPS
For a plain http:// URL, the client sends the whole request to the proxy, absolute URL included. The proxy can read it, cache it and add headers such as Via or X-Forwarded-For.
HTTPS works differently. The client sends CONNECT host:443, the proxy opens a TCP connection to that host and relays bytes in both directions. The TLS handshake happens between the client and the destination, so the proxy sees a hostname, a port and ciphertext. It can’t add a header to a request it can’t read. Over HTTPS, then, a forward proxy has no way to write your real address into X-Forwarded-For.
Authentication failures come back as 407 Proxy Authentication Required. A 407 always comes from the proxy; the request never reached the destination.
Reverse proxies are run by the server operator
A reverse proxy acts for the server. DNS for the public hostname points at the proxy, which accepts the connection on port 443, terminates TLS with the site’s certificate and passes the request to a backend on a private address. nginx with proxy_pass, HAProxy, Caddy with reverse_proxy, Traefik and Envoy are the common choices, and a CDN such as Cloudflare is the same thing run as a global service. RFC 9110 calls this role a gateway.
The backend sees the proxy, not the visitor
The backend’s TCP peer is the proxy. Without extra information, the backend recieves every request from one internal address such as 10.0.0.5 or 127.0.0.1.
HTTP reverse proxies solve this with X-Forwarded-For, X-Forwarded-Proto, X-Forwarded-Host and the standardised Forwarded header from RFC 7239. Raw TCP has no header to write into, so HAProxy introduced the PROXY protocol in 2010, which prepends the original address to the byte stream. When the backend is down, the reverse proxy answers with 502 Bad Gateway or 504 Gateway Timeout.
Reverse proxy vs forward proxy vs localhost tunnel
A forward proxy represents clients and a reverse proxy represents servers. Most forward proxy vs reverse proxy comparisons stop at those two columns. This one adds localhost tunnels as a third, because a tunnel shares rows with both.
| Forward proxy | Reverse proxy | Localhost tunnel | |
|---|---|---|---|
| Acts on behalf of | The client | The server | The server, here your own machine |
| Who configures it | The client: curl -x, HTTPS_PROXY, browser settings | The server operator; DNS points at the proxy | The developer, with one command |
| Connection direction | Client to proxy, proxy to origin | Client to proxy, proxy to backend | Visitor to edge; origin to edge, opened from the origin |
| Inbound port needed | None | 80 and 443 on a public address | None |
| Source address the app sees | The proxy’s exit IP | The proxy’s internal address, unless it reads forwarded headers | 127.0.0.1, unless it reads forwarded headers |
| TLS | Passed through with CONNECT, not decrypted | Terminated at the proxy, which holds the certificate | Terminated at the edge (HTTP tunnels) or passed through (TLS tunnels) |
| Characteristic errors | 407; 403 on a refused CONNECT | 502 or 504 when the backend is down or slow | 502 when nothing listens on the local port |
| Examples | Squid, ssh -D, commercial proxy providers | nginx, HAProxy, Caddy, Traefik, Cloudflare | Pinggy, ngrok, cloudflared, ssh -R |

Figure 1. Reverse proxy vs forward proxy: the first is the server operator’s tool, the second is the client’s.
Two rows settle most reverse proxy vs forward proxy confusion. “Inbound port needed” explains why tunnels exist: a classic reverse proxy needs a public address with port 443 open, and a laptop on hotel Wi-Fi or 4G has neither. “Source address the app sees” explains most bugs that appear the first time an app runs behind any proxy.
A localhost tunnel is a reverse proxy
A reverse proxy with the upstream connection turned around
In reverse proxy vs forward proxy terms, a localhost tunnel is a reverse proxy. The edge server owns the public hostname, terminates TLS and forwards requests to an origin. The unusual part is the leg between edge and origin: the proxy doesn’t dial the backend. The backend dials the proxy and keeps that connection open.
With Pinggy that leg is SSH remote forwarding. The -R0:localhost:3000 flag asks the server to allocate a public endpoint and send its traffic down the SSH session to port 3000 on the client. The SSH connection itself uses port 443, so it gets through firewalls that only allow outbound HTTPS. ngrok and cloudflared do the same job with their own agents and protocols.
Pinggy’s documentation says so directly: HTTP(S) tunnels run in reverse proxy mode by default and add X-Forwarded-For, X-Forwarded-Proto, X-Forwarded-Host and Forwarded to each request. The x:noreverseproxy argument switches that off, and x:haproxy enables the PROXY protocol on TCP tunnels.
You can build the same thing with any VPS: ssh -R 8080:localhost:3000 user@vps, plus nginx or Caddy in front for TLS. Two details catch people out. OpenSSH’s GatewayPorts option defaults to no, so the forwarded port binds to loopback only. And the session dies quietly on a flaky link unless ServerAliveInterval or autossh is set.
The forward proxy resemblance comes down to the direction of the first packet. The tunnel client dials out, as a browser behind a forward proxy would, and the likeness ends there. A tunnel doesn’t relay your outgoing requests anywhere.
Free tiers cap time, data or concurrency
The limits differ in kind. Pinggy’s free plan closes a tunnel after 60 minutes and issues a new random URL on restart, with no cap on data transfer. ngrok’s free plan has no session timeout but meters usage at 1 GB of outbound data and 20,000 HTTP requests a month, and it shows an interstitial page to browser GET requests. Cloudflare’s Quick Tunnels allow 200 in-flight requests, return 429 beyond that and don’t support Server-Sent Events.
A load test reaches the 1 GB and 200-request ceilings quickly, and a long demo runs into the 60-minute timer, which Pinggy’s paid plans (from $2.50 a month) replace with a persistent URL.
Test a tunnelled app through a forward proxy
A tunnel tells you the outside world can reach your app. It doesn’t tell you what the app does for a visitor in Frankfurt. Geo-based pricing, consent banners, language redirects and IP-keyed rate limits all depend on the visitor’s address, and from your desk every request carries the same one.
Here both proxy types meet in a single request. The forward proxy supplies a client address in another country. The tunnel, acting as the reverse proxy, delivers that request to localhost and records the address in a header.

Figure 2. The forward proxy changes who the visitor appears to be. The tunnel edge decides what the app is told about it.
Start the app, then start the tunnel with the web debugger port forwarded, and copy the HTTPS URL it prints:
ssh -p 443 -R0:localhost:3000 -L4300:localhost:4300 free.pinggy.ioSend one request directly and one through the proxy. For SOCKS5, use the
socks5h://scheme so that DNS is resolved at the proxy.curl https://TUNNEL_HOST/ curl -x http://USER:PASS@PROXY_IP:PORT https://TUNNEL_HOST/Open
http://localhost:4300and compare the two requests.X-Forwarded-Forshould hold your own address on the first and the proxy’s exit IP on the second.Repeat the proxied request against the plain
http://URL. Here the proxy can read the request, so look for aViaheader or your real address inX-Forwarded-For.Confirm that the app acted on the header: the response should carry the German price, banner or redirect.
Frameworks have to trust the tunnel hop
When step 3 fails, the cause is nearly always in the app. Behind a tunnel the socket peer is 127.0.0.1, because the SSH client on your machine makes the final connection. A framework that ignores forwarded headers by default therefore treats every visitor as local.
In Express, app.set('trust proxy', 'loopback') corrects req.ip. Without it, express-rate-limit logs ERR_ERL_UNEXPECTED_X_FORWARDED_FOR as soon as the header shows up. Django needs the tunnel hostname in ALLOWED_HOSTS, and SECURE_PROXY_SSL_HEADER set before request.is_secure() returns true. Vite’s dev server has rejected unknown Host headers since versions 5.4.12 and 6.0.9, so the tunnel hostname goes into server.allowedHosts.
The opposite mistake is worse. Trusting X-Forwarded-For from any source lets a client write its own address into your logs and rate limiter, so trust only the hop you know (loopback, in a tunnel setup) and read the value it appended. Pinggy’s guide to X-Forwarded-For and Forwarded headers covers the parsing rules and the spoofing cases in more depth.
A static proxy address has one more use. The w: option restricts a Pinggy tunnel to listed IPs or CIDR ranges and drops everything else without a response. Allowlisting one dedicated proxy IP keeps a staging build reachable for a remote tester and closed to scanners.
Forward proxy providers for tunnel testing
The requirements are modest: a handful of requests per test, a known country and, ideally, an address that stays the same so it can be allowlisted. That points to dedicated datacenter IPv4 proxies sold per IP, not to rotating pools sold per gigabyte.
| Provider | Dedicated datacenter IPv4, entry price | Smallest plan shown | Protocols | Relevant for tunnel tests |
|---|---|---|---|---|
| Proxys.io | $2.30 per IP for 1 to 4 IPs, $1.60 for 5 to 49 | 1 IP | HTTP(S) and SOCKS5 on each IP | 70+ countries; password or IP authorisation; 7 Mbps per proxy; 24-hour refund |
| IPRoyal | From $1.57 per IP; $1.48 on 60 days, $1.39 on 90 | Not stated on the pricing page | HTTP(S), SOCKS5 | 50+ countries |
| Webshare | About $1.33 per IP on a 20-IP dedicated plan ($26.60) | Free plan: 10 shared proxies, 1 GB a month | HTTP, SOCKS5 | Free tier covers a one-off header check; shared IPs suit allowlisting poorly |
| Decodo | $3.33 per IP on 3 IPs ($9.99 + VAT), $2.90 on 10 | 3 IPs | HTTP(S), SOCKS5 | 14-day money-back option |
| Bright Data | $2.20 per IP on 10 dedicated IPs; shared from $1.40; $0.60 per GB pay as you go | 10 IPs on per-IP plans | HTTP(S), SOCKS5 | Per-GB billing suits a few test requests |
Prices as listed when this post was published, for 30-day terms, before tax. Webshare figures come from published plan breakdowns and should be confirmed at checkout.
Proxys.io sells single dedicated IPv4 addresses in more than 70 countries, and each address answers on an HTTP(S) port and a SOCKS5 port, with login and password or IP-based authorisation. One IP costs $2.30 for 30 days, and the rate drops to $1.60 from five.
IPRoyal’s entry rate is $0.73 lower per IP. Webshare’s free plan costs nothing for a one-off header check. The Proxys.io channel is 7 Mbps per proxy (10 on request), which is enough for functional tests and too little for load tests.
City-level checks need residential addresses. Proxys.io prices those at $4 per GB with city targeting across 195 countries, but the exit IP rotates every 2 to 60 minutes, so it can’t be allowlisted.
Switching provider is worth it when the country you need is missing, when shared IPs make allowlisting pointless, or when a minimum order of 3 or 10 IPs means paying for idle addresses.
Pick by where the service runs
The reverse proxy vs forward proxy choice follows from where the service runs and which side needs representing.
- Your code makes outbound requests and the destination should see another address or country: forward proxy.
- Several services share a server with a public IP and need one TLS endpoint, routing and caching: reverse proxy.
- The service runs on a laptop, a Raspberry Pi or a container with no public address, and someone outside has to reach it: localhost tunnel.
- You need to see how that tunnelled service treats visitors from another region: tunnel plus forward proxy, as in the test above.
FAQ
Is a localhost tunnel a reverse proxy or a forward proxy?
A reverse proxy. It accepts requests for your server and adds forwarding headers. Only the connection from origin to edge is outbound.
Can a forward proxy act as a reverse proxy?
The same software often can: Squid has an accelerator mode, and nginx and Apache handle both roles. A given deployment is still one or the other, and a commercial forward proxy can’t publish your localhost, since it has no route to it.
Do I need both forward and reverse proxies in production?
Most teams already run both: a reverse proxy in front of the app, and forward proxies wherever outbound traffic has to leave from a controlled address. In development the tunnel stands in for the first. Add the second on the day a bug report says the problem only happens for users in another country, and reproduce it with one proxied curl before changing any code.