Skip to content

Commit fb4f8a9

Browse files
committed
Improve docs
1 parent 80efec2 commit fb4f8a9

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/net/http/httputil/reverseproxy.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,10 @@ import (
2525
// sends it to another server, proxying the response back to the
2626
// client.
2727
//
28-
// ReverseProxy automatically sets the client IP as the value of the
29-
// X-Forwarded-For header.
30-
// If an X-Forwarded-For header already exists, the client IP is
31-
// appended to the existing values.
32-
// To prevent IP spoofing, be sure to delete any pre-existing
33-
// X-Forwarded-For header coming from the client or
34-
// an untrusted proxy.
28+
// ReverseProxy automatically sets the X-Forwarded-For,
29+
// X-Forwarded-Host and X-Forwarded-Proto headers.
30+
// Previous values of these headers can be preversed by
31+
// setting TrustForwardedHeaders to true.
3532
type ReverseProxy struct {
3633
// Director must be a function which modifies
3734
// the request into a new request to be sent
@@ -86,11 +83,15 @@ type ReverseProxy struct {
8683
ErrorHandler func(http.ResponseWriter, *http.Request, error)
8784

8885
// TrustForwardedHeaders specifies if X-Forwarded-For,
89-
// X-Forwarded-Proto and X-Forwarded-Host headers comming from
86+
// X-Forwarded-Proto and X-Forwarded-Host headers coming from
9087
// the previous proxy must be trusted or not.
88+
//
9189
// If true, existing values of X-Forwarded-Proto and
9290
// X-Forwarded-Host will be preserved, and the current client IP
93-
// will be appended to the list in X-Forwarded-For.
91+
// will be appended to the list in X-Forwarded-For. In this case
92+
// be sure that these 3 headers are removed from the request if
93+
// sent by the client to prevent spoofing attacks.
94+
//
9495
// If false, values of these headers will be set regardless of
9596
// any existing value.
9697
TrustForwardedHeaders bool

0 commit comments

Comments
 (0)