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

Add support to use Proxy From Environment #462

Merged
merged 1 commit into from
Mar 8, 2023

Conversation

roidelapluie
Copy link
Member

This commit adds a new field ProxyFromEnvironment to the HTTPClientConfig and OAuth2 structs to enable Prometheus to use the default proxy from the environment variable (as specified in net/http ProxyFromEnvironment.) This is opt-out by default, so does not change anything for existing users.

This change is necessary because Prometheus previously had insufficient behavior to avoid proxying EC2 metadata requests when proxy_url is set in ec2_sd_configs.

See prometheus/prometheus#11991

// UnmarshalYAML implements the yaml.Unmarshaler interface.
func (c *ProxyConfig) Validate() error {
if len(c.ProxyConnectHeader) > 0 && (!c.ProxyFromEnvironment && (c.ProxyURL.URL == nil || c.ProxyURL.String() == "")) {
return fmt.Errorf("if proxy_connect_header is configured proxy_url or proxy_from_environment must also be configured")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small readability nit (applies to other messages too)

Suggested change
return fmt.Errorf("if proxy_connect_header is configured proxy_url or proxy_from_environment must also be configured")
return fmt.Errorf("if proxy_connect_header is configured, proxy_url or proxy_from_environment must also be configured")

config/http_config.go Show resolved Hide resolved
config/http_config.go Show resolved Hide resolved
config/http_config.go Show resolved Hide resolved
This commit adds a new field `ProxyFromEnvironment` to the
`HTTPClientConfig` and `OAuth2` structs to enable Prometheus to use the
default proxy from the environment variable (as specified in net/http
ProxyFromEnvironment.) This is opt-out by default, so does not change
anything for existing users.

This change is necessary because Prometheus previously had insufficient
behavior to avoid proxying EC2 metadata requests when `proxy_url` is
set in `ec2_sd_configs`.

This commit also adds the ability to support `no_proxy`.

See prometheus/prometheus#11991

Signed-off-by: Julien Pivotto <[email protected]>
Copy link
Member

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@roidelapluie roidelapluie merged commit 66b493f into prometheus:main Mar 8, 2023
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.

3 participants