-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add PROXY protocol support #3098
Conversation
…t cluster to allow modifying listeners before starting, and fix tests
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.
Looks good overall. Just a few comments.
command/server/config.go
Outdated
"tls_disable": "1", | ||
"address": "127.0.0.1:8200", | ||
"tls_disable": true, | ||
"proxy_protocol": "use_if_authorized", |
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 wonder if a nested proxy_protocol
block would be nicer here, with keys of behavior
and allowed_addrs
.
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 the answer is "yes" although we don't do that with tls, so I worry it would be sort of a "okay, why are they changing this up now" issue UX wise. We could support that later on and move tls and proxy both.
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.
See 5dea9eb for a quick change to address this at the moment.
helper/proxyutil/proxyutil.go
Outdated
Listener: listener, | ||
} | ||
|
||
if config.Behavior == "use_if_authorized" || config.Behavior == "deny_if_unauthorized" { |
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.
Could you move this up into your switch statement above?
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.
Done.
"net" | ||
"sync" | ||
|
||
proxyproto "github.com/armon/go-proxyproto" |
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.
This appears to be missing from the vendor directory.
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.
Yeah, stupid me, I got sockaddr and forgot proxyproto. Added.
helper/proxyutil/proxyutil.go
Outdated
AllowedAddrs []*sockaddr.SockAddrMarshaler `json:"allowed_addrs"` | ||
} | ||
|
||
func (p *ProxyProtoConfig) SetAllowedAddrs(addrs interface{}) 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.
This method could really use some unit tests to ensure the allowed addresses are being set correctly.
Also, can you add some docs for the config options. The behaviors especially took me a bit to get. |
… change to a struct later
Yeah, I'll make sure to add docs before merging this. |
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.
Just one small comment
helper/proxyutil/proxyutil.go
Outdated
} | ||
} | ||
|
||
if config.Behavior == "use_if_authorized" { |
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.
Not sure if this is a standard or not, but this name is pretty confusing to me. Should it be use_if_unauthorized
?
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.
maybe this should properly be "use_if_allowed" but I thought that might be even more confusing. Alternately I could change the name to "AuthorizedAddrs" instead of AllowedAddrs? (or maybe AuthorizedHosts?)
@jefferai I can barely explain how happy I am to see this! Thank you sooo much! |
:-D |
🎉 Thanks @jefferai! This is awesome! 😀 |
@jefferai any documentation on how to use this awesomeness? Am I reading wrong but it doesn't look like this part of the 0.8.0 release ? |
Fixes #799
Ping #815