HTTP proxy authentication: understanding 407 and credential headers
An HTTP proxy that requires access authorization challenges a request with 407 Proxy Authentication Required and a Proxy-Authenticate challenge. The client can retry with credentials in Proxy-Authorization, using a scheme accepted by that proxy. These credentials are separate from Authorization for the origin server; in a proxy chain, the next proxy that requested them consumes them.
An HTTP proxy that requires access authorization challenges a request with 407 Proxy Authentication Required and a Proxy-Authenticate challenge. The client can retry with credentials in Proxy-Authorization, using a scheme accepted by that proxy. These credentials are separate from Authorization for the origin server; in a proxy chain, the next proxy that requested them consumes them.
The proxy authentication exchange
GET http://example.com/resource HTTP/1.1
Host: example.com
HTTP/1.1 407 Proxy Authentication Required
Proxy-Authenticate: Basic realm="corporate proxy"
GET http://example.com/resource HTTP/1.1
Host: example.com
Proxy-Authorization: Basic <credentials>Proxy-Authenticate carries one or more schemes and parameters applicable to the proxy for this request. A proxy must include at least one challenge in every 407 response it generates. A client may send credentials after a challenge or preemptively if it decides they are needed. When credentials are absent, invalid, or incomplete, a proxy is recommended to respond with a 407 containing an applicable challenge. (RFC 9110 §§11.3, 11.7, 15.5.8)
Proxy headers versus origin headers
| Purpose | Challenge | Client credentials |
|---|---|---|
| Authenticate to the chosen proxy | 407 + Proxy-Authenticate | Proxy-Authorization |
| Authenticate a user to the origin server | 401 + WWW-Authenticate | Authorization |
Proxy-Authorization applies to the next inbound proxy that requested authentication. In a chain, the first such proxy consumes it. Proxy-Authenticate applies to the next outbound client on the response path—the client that selected that proxy. Do not reuse an origin server's Authorization as proxy login data or forward proxy credentials to the origin. (RFC 9110 §11.7)
Safer implementation and operations
Offer only authentication schemes the deployment supports. Basic encodes a username and password with Base64; it does not encrypt them, so protect the transport when using it over an untrusted network.
Keep secrets out of logs, error messages, and tracing data. Redact authentication fields and check that redirects or proxy changes cannot send credentials to an unintended recipient.
Verify the permitted user or service and destination policy. Distinguish missing, expired, malformed, and rejected credentials internally without exposing sensitive details in external responses.
Document which proxy hop issues each challenge and consumes each credential. Review credential forwarding inside a managed multi-proxy domain separately from a single-proxy flow.
Verify 407 retries, credential storage, TLS protection, and multi-proxy behavior with the actual client and proxy versions. HTTP does not define product login screens or credential-storage policy.
When should a proxy return 407?
Use 407 when a proxy requires the client to authenticate before it will perform the request. Use 401 when the origin server requires user authentication. The distinction tells the client which credential to provide and to whom.
References
[RFC 9110: HTTP Semantics §§11.3, 11.7, 15.5.8](https://www.rfc-editor.org/rfc/rfc9110.html)