Skip to content

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

Akshay2191
Copy link
Contributor

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.

  • I have read the CONTRIBUTING document
  • I have run make install-tools and have attached any dependency changes to this pull request
  • If applicable, I have added tests that prove my fix is effective or that my feature works
  • If applicable, I have checked that any relevant tests pass after adding my changes
  • If applicable, I have updated any relevant documentation (README.md)
  • If applicable, I have tested my cross-platform changes on Ubuntu 22, Redhat 8, SUSE 15 and FreeBSD 13

@Akshay2191 Akshay2191 requested a review from a team as a code owner August 7, 2025 16:26
@github-actions github-actions bot added chore Pull requests for routine tasks documentation Improvements or additions to documentation labels Aug 7, 2025
@dhurley dhurley added the v3.x Issues and Pull Requests related to the major version v3 label Aug 8, 2025
@@ -0,0 +1,35 @@
# Agent Proxy Support
Copy link
Collaborator

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) {
Copy link
Contributor

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 ?

Suggested change
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)
Copy link
Contributor

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

Suggested change
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)
Copy link
Contributor

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 {
Copy link
Contributor

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 ?

@Akshay2191 Akshay2191 requested review from dhurley and aphralG August 11, 2025 11:13

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Pull requests for routine tasks documentation Improvements or additions to documentation v3.x Issues and Pull Requests related to the major version v3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants