On this page 11 sections
A proxy relays traffic for the applications you point at it, and nothing else. A VPN adds a network interface, and the operating system sends everything through it, whichever program produced the packet. Both change the address a website sees. Only the VPN encrypts the hop between your machine and its server by default. A connection to an ordinary http:// proxy is plain TCP, and anyone on your network can read the hostnames, the plain-HTTP URLs and the proxy password inside it.
We ran a proxy and a VPN from the same server and captured each of those differences. The outputs below are the real ones.
The ten-second answer
| Proxy server | VPN (WireGuard, full tunnel) | |
|---|---|---|
| What it reroutes | Only programs configured to use it: a flag, an environment variable, a browser setting | Every packet the operating system routes into the tunnel interface |
| What it carries | HTTP requests, or TCP streams (CONNECT, SOCKS5) | IP packets: TCP, UDP, ICMP, DNS |
| Encryption to the server | None for an http:// proxy; TLS only with an https:// proxy URL |
Always (ChaCha20 and Poly1305) |
| Who resolves hostnames | The proxy, for HTTP proxies and socks5h; you, for socks5 |
Your configured resolver, reached through the tunnel unless it is on your LAN |
| What your network can read | The proxy address, CONNECT hostnames, plain-HTTP URLs, Basic credentials | UDP packets to one address and port |
| Can add headers that name you | Yes, on plain HTTP. Squid adds X-Forwarded-For by default |
No. It never parses HTTP |
| Setup | One setting per program, no admin rights | Admin rights, a virtual interface, new routes |
| When the server dies | Immediate error: curl: (7) Failed to connect |
Silent timeouts: curl: (28) Resolving timed out |
| Many exit addresses at once | Easy: one per request, session or program | One exit per tunnel |
| Pick it for | Scraping, testing from other locations, per-program routing | Whole-device privacy on untrusted networks, non-HTTP programs, reaching a private network |
How we tested
Five containers stand in for the internet. The client sits behind a router that plays the user’s ISP: it translates the client to 172.31.251.254, so that address means “you” in every result. One remote gateway at 172.31.251.2 runs both Squid on TCP 3128 and a WireGuard server on UDP 51820. The proxy and the VPN therefore exit from the same address, which keeps the comparison fair. The target is nginx returning the peer address it saw plus two request headers. The resolver is dnsmasq, logging every query with its source address.
| Role | Address | Software |
|---|---|---|
| Client | 172.31.250.10 | curl 8.14.1, wg-quick, dig, openssl, nc |
| ISP router and capture point | 172.31.250.254 and 172.31.251.254 | iptables MASQUERADE, tcpdump 4.99.4, tc netem |
| Gateway | 172.31.251.2 | Squid 6.9 on TCP 3128, WireGuard on UDP 51820 |
| Target | 172.31.251.80 | nginx 1.26.3 on ports 80 and 443 |
| Resolver | 172.31.251.53 | dnsmasq 2.90, answers for target.lab |
The client side of each mode is short:
# proxy mode: environment variables, read by curl and most HTTP libraries
export http_proxy=http://user:pass@172.31.251.2:3128
export https_proxy=http://user:pass@172.31.251.2:3128
# VPN mode: /etc/wireguard/wg0.conf, then `wg-quick up wg0`
[Interface]
PrivateKey = <client-private-key>
Address = 10.66.0.2/32
[Peer]
PublicKey = <gateway-public-key>
Endpoint = 172.31.251.2:51820
AllowedIPs = 0.0.0.0/0
# on the router, for the timing runs only: 20 ms each way = 40 ms more round trip
tc qdisc add dev eth0 root netem delay 20ms
tc qdisc add dev eth1 root netem delay 20ms
Squid did not ask for a password. curl sent one anyway because it was in the proxy URL, which is what a paid gateway would receive. The samples behind each number:
- Behaviour: one run of six client commands per mode, captured at the router, the target and the resolver at the same time.
- Timing: 9 HTTPS requests per mode, each in a fresh curl process, with 40 ms of round-trip time added.
- Bytes: 3 downloads of a 10 MiB file per mode, read from the client’s interface counters.
- Handshake: 5 cycles of restarting both WireGuard ends, timing the first and second request of each.
Everything ran on one machine, so treat absolute times as lab numbers. The gateway and the target were next to each other, which flatters the proxy in one specific way explained under speed.
What the destination sees
Both modes moved the address on curl’s requests from 172.31.251.254 to the gateway’s 172.31.251.2. The difference was in what the proxy added to a plain-HTTP request:
# proxy mode
$ curl -s http://target.lab/
peer=172.31.251.2 via=1.1 pw-gateway (squid/6.9) xff=172.31.251.254
$ curl -sk https://target.lab/
peer=172.31.251.2 via= xff=
# WireGuard mode, the same two requests
peer=172.31.251.2 via= xff=
peer=172.31.251.2 via= xff=
Squid replaced our address and then wrote the old one into an X-Forwarded-For header, next to a Via header that names the proxy and its version. That is Squid’s shipped behaviour: forwarded_for defaults to on, which appends the client address to every request it forwards. The macOS run on Squid 6.13 did the same, and also inserted Cache-Control: max-age=259200, a header the client never sent.
None of this can happen to HTTPS through the same proxy. For an https:// URL the client sends CONNECT, the proxy opens a byte tunnel, and the request inside is encrypted end to end. It cannot happen on the VPN at all, because WireGuard moves IP packets and has no idea what HTTP is.
on, off, transparent, delete and truncate. Check rather than assume: send one plain-HTTP request through a new gateway to an endpoint that echoes headers. Our study of default request headers shows what a client sends before any proxy touches it.Traffic the proxy never sees
A proxy only carries what a program hands it. With both proxy variables exported, we ran five more tools on the same client and recorded where each packet arrived from.
| Traffic from the client | No proxy, no VPN | Proxy via environment variables | WireGuard full tunnel |
|---|---|---|---|
| curl, plain HTTP | 172.31.251.254 | 172.31.251.2 | 172.31.251.2 |
| curl, HTTPS | 172.31.251.254 | 172.31.251.2 | 172.31.251.2 |
| openssl s_client to port 443 | 172.31.251.254 | 172.31.251.254 | 172.31.251.2 |
| One UDP datagram to port 9999 | 172.31.251.254 | 172.31.251.254 | 172.31.251.2 |
| ping (ICMP) | 172.31.251.254 | 172.31.251.254 | 172.31.251.2 |
| dig, as the resolver logged it | 172.31.251.254 | 172.31.251.254 | 172.31.251.2 |
curl obeyed the variables. The other four ignored them and left from the client’s own address, as if no proxy existed. None of those tools is broken: proxy variables are a convention that each program decides whether to read, which our guide to HTTP_PROXY, HTTPS_PROXY and NO_PROXY covers in detail. The macOS run showed the same split. curl and Python’s urllib went through Squid, whose log held exactly two lines, both CONNECT httpbin.org:443 TCP_TUNNEL/200. openssl, nc and dig reached httpbin.org directly and never appeared in it.
With WireGuard up, every row moved to the gateway. That is the routing table at work, not a convention. Here is what wg-quick up printed, and the routing rules it left behind:
[#] ip link add wg0 type wireguard
[#] wg setconf wg0 /dev/fd/63
[#] ip -4 address add 10.66.0.2/32 dev wg0
[#] ip link set mtu 1420 up dev wg0
[#] wg set wg0 fwmark 51820
[#] ip -4 route add 0.0.0.0/0 dev wg0 table 51820
[#] ip -4 rule add not fwmark 51820 table 51820
[#] ip -4 rule add table main suppress_prefixlength 0
[#] sysctl -q net.ipv4.conf.all.src_valid_mark=1
[#] iptables-restore -n
$ ip rule
0: from all lookup local
32764: from all lookup main suppress_prefixlength 0
32765: not from all fwmark 0xca6c lookup 51820
32766: from all lookup main
32767: from all lookup default
$ ip route get 172.31.251.80
172.31.251.80 dev wg0 table 51820 src 10.66.0.2 uid 0
Any packet without WireGuard’s own mark (0xca6c is 51820) is looked up in table 51820, whose only route is the tunnel. WireGuard marks its own encrypted UDP, so that traffic still leaves by the normal interface instead of looping back into itself.
Browsers are where the per-program limit bites hardest. RFC 8828 notes that HTTP proxies and most SOCKS proxies cannot carry UDP, so a browser set to use a proxy may run WebRTC connectivity checks outside it. That is the mechanism behind a WebRTC leak. A full-tunnel VPN closes that route for IPv4. Our tunnel listed only 0.0.0.0/0, so on a network with IPv6 it would need ::/0 as well, because wg-quick only routes what AllowedIPs names.
What your ISP or the café Wi-Fi can read
We captured on the router’s client-facing interface, which is where an ISP or a shared Wi-Fi network sits. In proxy mode, these strings were readable in the packets:
$ tcpdump -nn -A -r isp-proxy.pcap | grep -aoE 'CONNECT [a-z.]+:[0-9]+|GET http://[^ ]+|Proxy-Authorization: Basic [A-Za-z0-9=]+' | sort | uniq -c
1 CONNECT target.lab:443
1 GET http://target.lab/
2 Proxy-Authorization: Basic dXNlcjpwYXNz
$ echo dXNlcjpwYXNz | base64 -d
user:pass
Basic authentication is an encoding, not encryption. RFC 7617 states that the scheme is not secure unless it runs over something like TLS, and over an http:// proxy URL nothing provides that. The fix exists: curl speaks TLS to the proxy itself when the proxy URL starts with https://, if the provider offers such an endpoint. Even then, the TLS ClientHello inside the tunnel names the site in its server_name field (RFC 6066). The same capture also showed dig’s query for target.lab in clear on port 53, and openssl’s direct connection to port 443 carrying the name in its ClientHello.
In WireGuard mode the same position saw this, and nothing else:
33 IP 172.31.250.10 > 172.31.251.2.51820: UDP,
25 IP 172.31.251.2 > 172.31.250.10.42015: UDP,
packets on udp port 51820: 58, of which carry the string target.lab: 0
| Readable on the client’s network | Proxy (http:// URL) |
WireGuard |
|---|---|---|
| Which server you use | Yes, 172.31.251.2 port 3128 | Yes, 172.31.251.2 UDP port 51820 |
| Hostname of the site | Yes: CONNECT line, Host header, TLS SNI | No: 0 of 58 packets |
| Full URL of a plain-HTTP request | Yes: GET http://target.lab/ |
No |
| Proxy username and password | Yes, Base64 in Proxy-Authorization |
No password exists; the private key never leaves the device |
| Traffic from programs that ignore the proxy | Yes, sent directly and readable as usual | No, inside the tunnel |
The VPN did not make the hostname disappear. The VPN server decrypts every packet and forwards it, so the VPN operator now sits exactly where your ISP sat, with the same view of DNS and SNI. Encrypted Client Hello (RFC 9849, published March 2026) hides the SNI from every on-path observer, a VPN operator included, but only where both the site and the client support it.
Who resolves the hostname
An HTTP proxy resolves the name itself. In proxy mode the resolver logged exactly two lookups for target.lab from the gateway, one A and one AAAA, both made by Squid. curl made none, because it sent the hostname to the proxy instead of an address.
With SOCKS5 it depends on one letter. --socks5 resolves on your machine and sends the proxy an address; --socks5-hostname, which is the socks5h:// scheme, sends the name and lets the proxy resolve it. We ran both against a small logging SOCKS5 server and captured both ends, with curl’s verbose output trimmed to the SOCKS lines:
$ curl -sv --socks5 127.0.0.1:11080 https://httpbin.org/ip -o /dev/null
* Host httpbin.org:443 was resolved.
* SOCKS5 connect to 54.174.189.226:443 (locally resolved)
* SOCKS5 request granted.
$ curl -sv --socks5-hostname 127.0.0.1:11080 https://httpbin.org/ip -o /dev/null
* SOCKS5 connect to httpbin.org:443 (remotely resolved)
* SOCKS5 request granted.
# what the SOCKS5 server received
ATYP=0x01 (IPv4 address) -> 54.174.189.226:443
ATYP=0x03 (domain name) -> httpbin.org:443
ATYP is the address-type byte from RFC 1928: 0x01 for an IPv4 address, 0x03 for a domain name, 0x04 for IPv6. The server is about 50 lines of standard-library Python, tested on Python 3.15.0. Run it and point any SOCKS client at port 1080 to see which kind your client sends:
#!/usr/bin/env python3
"""socks5_log.py: a minimal SOCKS5 server (RFC 1928, CONNECT only, no auth)
that prints what each client asked for, so you can see where DNS happened."""
import asyncio
import socket
import sys
PORT = int(sys.argv[1]) if len(sys.argv) > 1 else 1080
ATYP = {1: "IPv4 address", 3: "domain name", 4: "IPv6 address"}
async def pipe(reader, writer):
try:
while data := await reader.read(65536):
writer.write(data)
await writer.drain()
finally:
writer.close()
async def handle(reader, writer):
_ver, nmethods = await reader.readexactly(2)
await reader.readexactly(nmethods)
writer.write(b"\x05\x00") # SOCKS5, no authentication
_ver, cmd, _rsv, atyp = await reader.readexactly(4)
if atyp == 1:
host = socket.inet_ntop(socket.AF_INET, await reader.readexactly(4))
elif atyp == 4:
host = socket.inet_ntop(socket.AF_INET6, await reader.readexactly(16))
else:
size = (await reader.readexactly(1))[0]
host = (await reader.readexactly(size)).decode()
port = int.from_bytes(await reader.readexactly(2), "big")
print(f"ATYP={atyp:#04x} ({ATYP.get(atyp)}) -> {host}:{port}", flush=True)
if cmd != 1: # only CONNECT is implemented
writer.write(b"\x05\x07\x00\x01" + bytes(6))
writer.close()
return
up_r, up_w = await asyncio.open_connection(host, port) # a name resolves HERE
writer.write(b"\x05\x00\x00\x01" + bytes(6)) # success, bound address 0.0.0.0:0
await writer.drain()
await asyncio.gather(pipe(reader, up_w), pipe(up_r, writer))
async def main():
server = await asyncio.start_server(handle, "127.0.0.1", PORT)
async with server:
await server.serve_forever()
asyncio.run(main())
On the VPN side the question is where your resolver lives. In our lab it was off-link at 172.31.251.53, so queries went into the tunnel and arrived from the gateway’s address. A resolver on your own LAN would not. The rule table main suppress_prefixlength 0 lets every route in the main table win except the default route, including the route for your own LAN, and with the tunnel up, ip route get 172.31.250.1 still answered dev eth0. Setting DNS = in the WireGuard config moves resolution to a server across the tunnel; wg-quick then hands that address to resolvconf. Our DNS leak entry covers how to test it.
Speed and overhead
We downloaded the same 10,485,760-byte file over plain HTTP three times per mode and read the client’s rx_bytes counter, with segmentation and receive offloads switched off on every interface so the counter saw wire-sized frames. The counter includes the 14-byte Ethernet header.
| Path | Received (MB) | Over payload | Frames |
|---|---|---|---|
| Direct | 10.96 | 4.56% | 7,247 |
| HTTP proxy (Squid) | 10.99 | 4.84% | 7,684 |
| WireGuard | 11.45 | 9.22% | 7,671 |
Exact medians: 10,964,376 bytes direct, 10,993,241 through the proxy and 11,452,674 through WireGuard. Direct was identical in all three runs; the other two varied by at most 1,632 bytes. WireGuard cost 4.45% more on the wire than going direct. The protocol page explains why: each data message carries a 16-byte header and a 16-byte authentication tag, the payload is padded to a multiple of 16 bytes, and the whole thing rides in UDP and IP. wg-quick allows for that by setting the tunnel MTU to the path MTU minus 80, which is the mtu 1420 in the output above. The proxy cost almost nothing in bytes; Squid relayed the file in slightly smaller segments, hence 437 extra frames.
Time is where the lab surprised us. With 40 ms of round-trip time added on the router, these are the medians of 9 HTTPS requests per mode, each in a fresh curl process:
| Path | Name lookup done (ms) | TCP connected (ms) | TLS done (ms) | First byte (ms) |
|---|---|---|---|---|
| Direct | 41.7 | 86.5 | 137.7 | 182.8 |
| HTTP proxy | 0.0 | 41.6, to the proxy | 138.0, includes CONNECT | 183.6 |
| WireGuard, tunnel already up | 42.3 | 87.1 | 137.3 | 182.3 |
The proxy spends a whole extra round trip on CONNECT: 96 ms from TCP connected to TLS done, against 51 ms direct. It won that round trip back by skipping the DNS lookup, which Squid made next door to the resolver. On the real internet that refund shrinks, because the proxy has its own distance to the resolver and to the target, and our gateway sat beside both. WireGuard added nothing per request once the tunnel was up.
It does add one round trip when a session starts. Across 5 cycles of restarting both ends, the first request after wg-quick up finished its name lookup in 87 to 102 ms and completed in 229 to 256 ms. The second request in each cycle took 42 to 46 ms and 188 to 198 ms. The difference is the two-message handshake that the first packet triggers.
Neither result tells you how a commercial proxy pool or VPN service performs, which depends on where its servers are and how loaded they are. If speed through proxies is your actual question, start with residential vs datacenter vs ISP vs mobile, which covers how the type of address behind a proxy affects its speed and cost.
When the far end goes away
We stopped each server while the client kept working. The proxy failed fast and loudly:
# Squid stopped on the gateway (Alpine lab, curl 8.14.1)
curl: (7) Failed to connect to 172.31.251.2 port 3128 after 0 ms: Could not connect to server
# the same on macOS, curl 8.7.1 and Python 3.15.0 urllib
curl: (7) Failed to connect to 127.0.0.1 port 13128 after 0 ms: Couldn't connect to server
urllib.error.URLError: <urlopen error [Errno 61] Connection refused>
WireGuard failed slowly and quietly. It keeps no connection that can break and reports no errors to programs, so with the server’s interface removed, requests simply stopped getting replies. The status line at the end is from the client, after both timeouts:
$ curl -sS -k -m 8 https://target.lab/
curl: (28) Resolving timed out after 8005 milliseconds
$ curl -sS -k -m 8 https://172.31.251.80/
curl: (28) Connection timed out after 8003 milliseconds
$ wg show wg0 # trimmed
latest handshake: 16 seconds ago
transfer: 2.40 KiB received, 3.23 KiB sent
The first error is about DNS, not the site, because the lookup was the first thing to enter the dead tunnel. That is a useful tell: a VPN problem often looks like a DNS problem. In both failures the target received 0 packets from the client’s own address, so neither setup fell back to a direct connection on its own.
Fallback is where real setups differ from this lab. A browser proxy auto-config file that returns PROXY gw.example.net:8080; DIRECT tells the browser to go direct, without asking, when the proxy is unreachable. On the VPN side, taking the tunnel down with wg-quick down restores the normal routes and traffic leaves unprotected; the wg-quick manual shows a kill-switch rule built on the same fwmark for people who need that closed.
When a proxy is the right choice
Choose a proxy when the routing decision belongs to one program, or to one request. A scraper can use a different exit address for every request, or hold one for a session, which is the subject of rotating vs sticky sessions. Ten scrapers on one machine can use ten countries at once. A full-tunnel VPN gives the whole machine one exit at a time.
A proxy also needs no administrator rights. Setting -x in curl or a proxies dictionary in Python changes nothing for the rest of the system; see using a proxy with curl and proxies in Python. And because an HTTP proxy understands HTTP, it can filter, cache and log by URL, which is why companies run them at the network edge. In the macOS run, Squid’s access log showed how much it sees: it recorded our plain-HTTP request as GET http://127.0.0.1:29080/page?, with the query removed only because strip_query_terms defaults to on.
Use HTTPS to the target, or an https:// proxy URL, whenever the network between you and the proxy is not yours.
When a VPN is the right choice
Choose a VPN when the whole device should be covered, including programs you cannot configure. Games, voice calls, SSH, mail clients, system updates and the browser’s WebRTC stack all go through it without any per-program setting. On a hotel or café network it hides from the local network everything we saw leaking in proxy mode: the hostnames, the DNS queries, the proxy password.
It is also the tool for reaching a private network, an office or a home server, because it gives you an address inside that network rather than a relay in front of one website. What it does not do is hide your activity from the VPN operator, or change how a website fingerprints your client. Neither a VPN nor a CONNECT tunnel alters the TLS ClientHello your software sends, which is the layer our TLS ClientHello research measures.
Using both, and where the line blurs
The two stack. With a VPN up, a program can still use a proxy. The proxy then sees the VPN server’s address, not yours. The VPN operator sees your connection to the proxy, which includes the CONNECT line and any Basic credentials unless the proxy URL is https://. The website sees whichever exit is last in the chain, which here is the proxy.
The protocols are also converging. RFC 9484, published in October 2023, describes how to proxy IP packets in HTTP, so an HTTP proxy that implements it carries whole IP packets exactly as a VPN does. For the ordinary tools people mean when they ask this question, an HTTP or SOCKS5 proxy and a WireGuard or OpenVPN tunnel, the split in the table at the top still holds. If you are new to the proxy half, what is a proxy server starts from the beginning.
Frequently asked questions
Is a VPN a proxy?
Which is better, a VPN or a proxy?
Does a proxy encrypt my traffic?
How do I tell if I am using a VPN or a proxy?
Can a website tell I am using a proxy or a VPN?
Does a VPN stop DNS leaks?
Sources
- RFC 9110: HTTP Semantics, the CONNECT method
- RFC 9110: HTTP Semantics, the Via header
- RFC 7617: The 'Basic' HTTP Authentication Scheme
- RFC 1928: SOCKS Protocol Version 5
- RFC 6066: TLS Extensions, including Server Name Indication
- RFC 9849: TLS Encrypted Client Hello
- RFC 8828: WebRTC IP Address Handling Requirements
- RFC 9484: Proxying IP in HTTP
- WireGuard: overview, interface model and cryptography
- WireGuard: protocol and message formats
- wg-quick(8) manual page
- wg-quick source (linux.bash): MTU minus 80 and policy routing
- Squid configuration reference: forwarded_for
- Squid configuration reference: strip_query_terms
- curl man page: --proxy, --socks5, --socks5-hostname, proxy environment variables
- MDN: Proxy Auto-Configuration (PAC) file