Skip to content

Add proxy protocol v2 client-side support #979

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 2 commits into
base: main
Choose a base branch
from

Conversation

defanator
Copy link

@defanator defanator commented Feb 17, 2025

Proposed changes

This PR introduces support for proxy protocol v2 which is available in nginx starting from versions 1.13.11 (foss) and R16 (NGINX Plus).

Primary use case is running nginx-prometheus-exporter alongside with nginx or NGINX Plus sitting behind other load balancers like AWS NLB or Google's PNLB with proxy protocol enabled. Sometimes creating dedicated listeners just for stub_status or API could be undesired, and with the proposed changes the exporter will be able to reuse existing listeners without extra effort.

Changes were tested with the following combinations of listeners:

  1. IPv4 with proxy_protocol, IPv4 without proxy_protocol.
  2. IPv6 with proxy_protocol, IPv6 without proxy_protocol.
  3. Unix socket with proxy_protocol, unix socket without proxy_protocol (not that common scenario, but still supported by standard).

Implementation used: https://github.com/pires/go-proxyproto

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING guide
  • I have proven my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have ensured the README is up to date
  • I have rebased my branch onto main
  • I will ensure my PR is targeting the main branch and pulling from my branch on my own fork

@defanator defanator requested a review from a team as a code owner February 17, 2025 06:34
Copy link

github-actions bot commented Feb 17, 2025

✅ All required contributors have signed the F5 CLA for this PR. Thank you!
Posted by the CLA Assistant Lite bot.

@github-actions github-actions bot added documentation Pull requests/issues for documentation dependencies Pull requests that update a dependency file labels Feb 17, 2025
@defanator
Copy link
Author

I have hereby read the F5 CLA and agree to its terms

@defanator
Copy link
Author

For the reference, here's the linter output from a platform I've been testing on:

nginx-prometheus-exporter % make lint
go run github.com/golangci/golangci-lint/cmd/[email protected] run --fix

nginx-prometheus-exporter % go version
go version go1.24.0 darwin/amd64

nginx-prometheus-exporter % sw_vers 
ProductName:            macOS
ProductVersion:         15.3
BuildVersion:           24D60

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file documentation Pull requests/issues for documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants