-
Notifications
You must be signed in to change notification settings - Fork 11
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
Configurable http and https proxy addrs #22
Conversation
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 left a few comments and I have a few more, but before we can restructure this we should align on whether we want the env variables or configuration to take precedence.
https.go
Outdated
@@ -559,10 +559,15 @@ func (proxy *ProxyHttpServer) connectDialProxyWithContext(ctx *ProxyCtx, proxyHo | |||
return c, nil | |||
} | |||
|
|||
// httpsProxyFromEnv allows goproxy to respect no_proxy env vars | |||
// httpsProxy allows goproxy to respect no_proxy env vars |
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 extend this comment to clarify which configuration takes precedent?
https.go
Outdated
// https://github.com/stripe/goproxy/pull/5 | ||
func httpsProxyFromEnv(reqURL *url.URL) (string, error) { | ||
func httpsProxy(reqURL *url.URL, httpProxyAddr string) (string, 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.
Could you change the var name to httpsProxyAddr
to be more accurate?
proxy.go
Outdated
@@ -191,7 +230,26 @@ func NewProxyHttpServer() *ProxyHttpServer { | |||
}), | |||
Tr: &http.Transport{TLSClientConfig: tlsClientSkipVerify, Proxy: http.ProxyFromEnvironment}, | |||
} | |||
proxy.ConnectDial = dialerFromEnv(&proxy) | |||
|
|||
cfg := httpproxy.FromEnvironment() |
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'm not sure about silently overriding environment proxy variables. WDYT?
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.
Also could we name this something to signal what it actually is instead of just cfg
?
I am planning to make the configuration take precedence and fall back to environment variable when configuration is not set. |
Summary
Allow setting the httpProxyAddr and httpsProxyAddr directly in
ProxyHttpServer
constructor. If these addresses are not set, use the default values from environment.Motivation
stripe/smokescreen uses this library for the proxy server. Currently, the only way to set the transport proxy for smokescreen are setting the proxy from environment, which requires us to set the environment variables like HTTP_PROXY, HTTPS_PROXY. We would like to have a more robust way of configuring the smokescreen server's transport proxy. Thus we are adding the transport proxy address as another configurations for the smokescreen server and the goproxy library it uses underneath.