-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to use "X-Forwarded-For" as a source of IP for white list. #3070
Conversation
5ed4797
to
5c3c220
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job @ldez 👏
First review with few comments :)
| `traefik.frontend.rateLimit.rateSet.<name>.period=6` | See [rate limiting](/configuration/commons/#rate-limiting) section. | | ||
| `traefik.frontend.rateLimit.rateSet.<name>.average=6` | See [rate limiting](/configuration/commons/#rate-limiting) section. | | ||
| `traefik.frontend.rateLimit.rateSet.<name>.burst=6` | See [rate limiting](/configuration/commons/#rate-limiting) section. | | ||
| `traefik.frontend.rateLimit.rateSet.<name>.period=6` | See [rate limiting](/configuration/commons/#rate-limiting) section. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the order changed between traefik.frontend.rateLimit.rateSet.<name>.period
and traefik.frontend.rateLimit.extractorFunc
?
server/header_rewriter.go
Outdated
@@ -12,7 +11,7 @@ import ( | |||
|
|||
// NewHeaderRewriter Create a header rewriter | |||
func NewHeaderRewriter(trustedIPs []string, insecure bool) (forward.ReqRewriter, error) { | |||
IPs, err := whitelist.NewIP(trustedIPs, insecure) | |||
IPs, err := whitelist.NewIP(trustedIPs, insecure, true) // FIXME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// FIXME
?
server/server_test.go
Outdated
errMessage: "parsing CIDR whitelist [foo]: parsing CIDR white list <nil>: invalid CIDR address: foo", | ||
}, | ||
{ | ||
desc: "whitelists configured )", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whitelists configured
instead of whitelists configured )
3091863
to
f535250
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Impressive job @ldez 👏
I think we definitely need a user guide (in the future) on chaining Traefik with another LB that would also explain X-Forwarded-For
and white listing.
} | ||
|
||
// contains checks if provided address is in the white list | ||
func (ip *IP) contains(addr string) (bool, net.IP, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the returned bool
still needed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes due to insecure
management.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I misunderstood the code initially.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few comments
docs/configuration/backends/file.md
Outdated
@@ -54,7 +54,10 @@ Træfik can be configured with a file. | |||
"test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", | |||
"test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0", | |||
] | |||
whitelistSourceRange = ["10.42.0.0/16", "152.89.1.33/32", "afed:be44::/16"] | |||
|
|||
[frontends.frontend2.whiteList] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that it should be frontend1
instead of frontend2
docs/configuration/entrypoints.md
Outdated
@@ -112,7 +115,8 @@ Redirect.Regex:http://localhost/(.*) | |||
Redirect.Replacement:http://mydomain/$1 | |||
Redirect.Permanent:true | |||
Compress:true | |||
WhiteListSourceRange:10.42.0.0/16,152.89.1.33/32,afed:be44::/16 | |||
WhiteList.SourceRange:10.42.0.0/16,152.89.1.33/32,afed:be44::/16 | |||
WhiteList.useXForwardedFor:true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be WhiteList.UseXForwardedFor
instead of WhiteList.useXForwardedFor
83f9a65
to
857e42b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I was looking at this PR as it reflected some functionality we had implemented in a fork, and as it's implemented here it doesn't seem secure (or at least has a large foot gun). As I understand from this test: + {
+ desc: "allow UseXForwardedFor, remoteAddr not in range, UseXForwardedFor in range",
+ whiteList: []string{"1.2.3.4/24"},
+ allowXForwardedFor: true,
+ remoteAddr: "10.2.3.1:123",
+ xForwardedForValues: []string{"1.2.3.1", "10.2.3.1"},
+ expected: true,
+ }, If my whitelist is set to What nginx does, which I think it safer, is it only allows you to pass the whitelist if all the IPs pass the whitelist. So in this case, nginx would fail because the |
What does this PR do?
Adds the ability to use
X-Forwarded-For
as a source of IP for white list.waiting for Segment labels: Docker #3055Motivation
Fixes #2942
More
Additional Notes
Related to #2260