-
Notifications
You must be signed in to change notification settings - Fork 97
Explicit forward proxy support for HTTP with Basic Auth #1201
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
base: main
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,35 @@ | |||
# Agent Proxy Support |
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.
We should add this to the official NGINX docs https://github.com/nginx/documentation
@@ -409,6 +418,14 @@ func (oc *Collector) restartCollector(ctx context.Context) { | |||
} | |||
} | |||
|
|||
func (oc *Collector) setProxyIfNeeded(ctx context.Context) { |
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 this be renamed to just setProxy ?
func (oc *Collector) setProxyIfNeeded(ctx context.Context) { | |
func (oc *Collector) setProxy(ctx context.Context) { |
if authLower == "basic" { | ||
setProxyWithBasicAuth(ctx, proxy, parsedProxyURL) | ||
} else { | ||
slog.ErrorContext(ctx, "Unknown auth type for proxy; Aborting Proxy Setup", "auth", auth, "url", proxyURL) |
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 this error be updated to match the format of our other errors ? something like
slog.ErrorContext(ctx, "Unknown auth type for proxy; Aborting Proxy Setup", "auth", auth, "url", proxyURL) | |
slog.ErrorContext(ctx, "Unknown auth type for proxy, unable to configure proxy for collector", "auth", auth, "url", proxyURL) |
slog.ErrorContext(ctx, "Failed to set Proxy", "error", setenvErr) | ||
} | ||
if setenvErr := os.Setenv("HTTPS_PROXY", proxyEnvURL); setenvErr != nil { | ||
slog.ErrorContext(ctx, "Failed to set Proxy", "error", setenvErr) |
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.
Same as above
return http.ReadResponse(bufio.NewReader(conn), nil) | ||
} | ||
|
||
func wrapProxyError(ctx context.Context, msg string, err error, proxyURL 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.
Why do we need to wrap the proxy error ?
internal/config/config.go
Outdated
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 we use the full name for explicit forward proxy instead of EFP?
Proposed changes
Describe the use case and detail of the change. If this PR addresses an issue on GitHub, make sure to include a link to that issue using one of the supported keywords here in this description (not in the title of the PR).
Checklist
Before creating a PR, run through this checklist and mark each as complete.
CONTRIBUTING
documentmake install-tools
and have attached any dependency changes to this pull requestREADME.md
)