An HTTP proxy is a server that receives a client's HTTP requests, forwards them to the destination server, and passes the responses back. For HTTPS sites, the client uses the CONNECT method to open a tunnel through the proxy, which then relays the encrypted traffic without being able to read it.
An HTTP proxy can read and even modify unencrypted HTTP traffic that passes through it, so sensitive data should travel over HTTPS, where the proxy only tunnels the encrypted traffic.
How an HTTP Proxy Handles a Request
- The client sends its request to the proxy instead of the website. For plain HTTP, it uses the full target URL; for HTTPS, it sends a
CONNECT host:443request. - If the proxy requires a login, the client adds a
Proxy-Authorizationheader. - For HTTP, the proxy forwards the request to the destination. For CONNECT, it replies with a 2xx status and switches to tunnel mode.
- The response travels back through the proxy to the client.
Forward, Reverse and Transparent HTTP Proxies
- Forward proxy: acts for clients and can hide their identity from websites. Users can set one up to hide their IP address while browsing.
- Reverse proxy: acts on behalf of web servers, handling jobs such as load balancing and caching static content.
- Transparent (intercepting) proxy: placed in the network path, so clients don't configure it and may not know it's there.
HTTP Proxy vs. SOCKS5 Proxy
| HTTP proxy | SOCKS5 proxy | |
|---|---|---|
| What it understands | HTTP requests and responses | Nothing above the transport layer; it relays data without reading it as HTTP |
| Traffic it carries | Web traffic, with HTTPS passed through a CONNECT tunnel | TCP and UDP for any app that supports SOCKS |
Can add headers such as Via | Yes | No |
| In curl | Default type when the proxy has no scheme | Set with a socks5:// or socks5h:// proxy URL |
Caching
Some HTTP proxies store responses to reduce traffic leaving a network. MDN calls these proxy caches, a kind of shared cache. Sites mark personalized responses with Cache-Control: private so shared caches don't store them. HTTPS responses usually pass through a proxy in a tunnel, so in many cases the proxy can't cache them.
What It Means for Web Scraping
- HTTP is often the default: curl treats a proxy given without a scheme, such as
proxy.example.com:8080, as an HTTP proxy. See proxy settings for where clients store this. - Headers can reveal the proxy: proxies may add a
Viaheader, and some add X-Forwarded-For with the original client IP. Check what a proxy sends before relying on it to hide your address.