TodayTools

Forward proxy with CONNECT

How HTTP proxy works

A middleman your browser asks to fetch for it

Donate
L7ApplicationPort 3128, 8080TCP
What brings you here?

Watch it happen

How much detail

The browser hands a full http:// address to the proxy, which fetches the page and passes it back.

Lucas's laptop
Office proxy
Internet
DNS resolver
www.example.com
CableInternetSetupRequestLookupResponse

4 steps, 10 packets

First up: Connect to the proxy. Press Play to watch it happen, one step at a time.

0 of 40/4

What is HTTP proxy?

A forward proxy sits between your device and the internet. Instead of connecting to websites itself, your browser asks the proxy to do it. For plain http:// pages the proxy fetches the page and hands it back; for https:// sites it opens a CONNECT tunnel and just passes encrypted bytes along.

Offices, schools and some apps use proxies to share one internet exit, cache popular files, log access and block unwanted sites. Knowing how a proxy works explains settings like HTTP_PROXY, errors like 407 and why HTTPS still stays private through one.

Think of it like this. A forward proxy is like a company mail room. You do not post letters yourself; you hand them to the mail room, which sends them from the company address and brings the replies back. For sealed envelopes (HTTPS) the mail room can see the address on the front, but not the letter inside.

Step by step

Plain HTTP

4 steps

The browser hands a full http:// address to the proxy, which fetches the page and passes it back.

  1. 1

    Connect to the proxy

    TCP to port 3128

    With a proxy set, the browser never connects to websites itself. It opens TCP to the proxy's address and port.

  2. 2

    Ask with the full URL

    GET http://www.example.com/news

    A request to a proxy carries the whole address, scheme and host included (absolute form). That tells the proxy where to go.

  3. 3

    Proxy fetches

    Its own DNS lookup and connection

    The proxy looks up the name, connects from its own public address and sends a normal request. It adds a Via header, and often X-Forwarded-For, so the chain is visible.

  4. 4

    Answer relayed

    200 OK, maybe cached

    The proxy passes the response back. A caching proxy keeps a copy, so the next person who asks gets it from the office instead of the internet. It can also log the visit and apply rules.

CONNECT tunnel

4 steps

For an https:// site the browser asks the proxy for a raw tunnel, then runs TLS straight to the server.

  1. 1

    CONNECT

    Open a tunnel to www.example.com:443

    For HTTPS the browser cannot hand the proxy a readable request. It sends CONNECT with only a host and port.

  2. 2

    Tunnel ready

    200 Connection established

    The proxy opens TCP to the server and answers with a 2xx status. From now on it just copies bytes both ways.

  3. 3

    TLS through the tunnel

    The handshake is end to end

    The browser runs TLS with the real server through the tunnel. The certificate check is against www.example.com, so the proxy cannot quietly read or change anything.

  4. 4

    Encrypted traffic

    The proxy sees only sizes

    Requests and responses pass through as encrypted records. The proxy knows the host name and how many bytes moved, and nothing else. Some companies install their own root certificate to inspect HTTPS; that only works on devices they manage.

Login and rules

4 steps

The proxy asks for a login with 407, then blocks a site the office policy does not allow.

  1. 1

    407 challenge

    Proxy Authentication Required

    This proxy only serves known staff. It answers the first request with 407 and a Proxy-Authenticate header naming the login methods it accepts.

  2. 2

    Retry with a login

    Proxy-Authorization header

    The browser sends the request again with Proxy-Authorization. Basic login is only base64, which anyone can decode, so offices prefer Negotiate (Kerberos) or a TLS connection to the proxy.

  3. 3

    Allowed

    Fetched as normal

    With a valid login the proxy fetches the page and logs it against the user.

  4. 4

    Blocked by policy

    403 from the proxy

    A request for a site on the block list never leaves the office. The proxy answers 403 itself with an explanation page.

Myths and mix-ups

  • A proxy does not break HTTPS; with CONNECT it only sees the host name and byte counts.
  • A proxy is not a VPN; only apps set to use it send traffic through it.
  • Ports 3128 and 8080 are not special; any port works if both sides agree.
  • Basic proxy login is not encrypted; base64 can be decoded by anyone who sees it.

Try it yourself

Run these on your own computer to see HTTP proxy at work.

  • Plain request through a proxy

    curl -v -x http://proxy.example.com:3128 http://example.com/

    Replace with your proxy address. The request line shows the full URL.

  • Watch a CONNECT tunnel

    curl -v -x http://proxy.example.com:3128 https://example.com/

    Look for CONNECT example.com:443 and then 200 Connection established before the TLS lines.

  • See your proxy settings

    env | grep -i proxy

    Many command-line tools follow HTTP_PROXY, HTTPS_PROXY and NO_PROXY.

HTTP proxy at a glance

Layer
Application (7)
Common ports
3128, 8080 (by habit, not official)
Transport
TCP
Tunnel method
CONNECT host:443
Login status
407 Proxy Authentication Required
Headers
Via, Proxy-Authorization, Proxy-Authenticate
Set by
Manual settings, a PAC file or HTTP_PROXY variables

Defined inRFC 9110 (HTTP semantics, CONNECT, 407, Via)RFC 9112 (HTTP/1.1, absolute-form requests)

Header fields

What HTTP proxy puts in its messages, with example values from the stories above.

HTTP/1.1

Request target
http://www.example.com/newsAbsolute form: only used when talking to a proxy. A normal server request would say just /news.
Host
www.example.com
Via
1.1 proxy.example.comProxies must add Via, so loops and chains can be spotted.
X-Forwarded-For
10.0.0.15Optional. Shows who asked first. Privacy-minded proxies leave it out.
Status
200 Connection establishedAny 2xx status means the tunnel is open.
Cache-Control
public, max-age=300Allows shared caches like this proxy to keep the page for 5 minutes.
Method
CONNECTAsks the proxy for a two-way byte pipe instead of a page.
Proxy-Authenticate
Negotiate, Basic realm="Office proxy"Lists the login methods the proxy accepts, strongest first.
Proxy-Authorization
Basic bHVjYXM6...Base64 of user:password. It is encoding, not encryption, so it must only cross trusted or encrypted links.

Test yourself

Question 1 of 4Score 0

How does a request to a proxy differ from a request to a web server?

Questions people ask

What is the difference between a forward proxy and a reverse proxy?

A forward proxy works for the users: it sends their requests out to many websites. A reverse proxy works for the website: it receives requests from the internet for one site and passes them to the right server inside.

What port does an HTTP proxy use?

There is no fixed port. 3128 and 8080 are the most common, and 80 or 443 are also used. Your network admin or PAC file tells your device which one.

Can a proxy see my HTTPS traffic?

Not normally. It sees the site name and how much data moved. Only if your device trusts a root certificate made by the proxy's owner can it decrypt, which companies do on devices they manage.

What does 407 Proxy Authentication Required mean?

The proxy wants you to log in before it will fetch anything. Your browser usually asks for the office username and password or signs in for you.

Is an HTTP proxy the same as a VPN?

No. A proxy handles only the apps that are set to use it, request by request. A VPN carries all traffic from the device at the IP level.

Donate