Skip to content
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

Merged
merged 2 commits into from
Nov 13, 2023

Conversation

xieyuxi-stripe
Copy link

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.

@xieyuxi-stripe xieyuxi-stripe changed the title Customizable http and https proxy addrs Configurable http and https proxy addrs Nov 8, 2023
Copy link

@cds2-stripe cds2-stripe left a 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

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) {

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()

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?

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?

@xieyuxi-stripe
Copy link
Author

I am planning to make the configuration take precedence and fall back to environment variable when configuration is not set.

@xieyuxi-stripe xieyuxi-stripe merged commit dbbdf2f into master Nov 13, 2023
5 checks passed
@xieyuxi-stripe xieyuxi-stripe deleted the xieyuxi/custom-transport-proxy-addr branch November 13, 2023 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants