-
Notifications
You must be signed in to change notification settings - Fork 369
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
base: main
Are you sure you want to change the base?
Conversation
✅ All required contributors have signed the F5 CLA for this PR. Thank you! |
I have hereby read the F5 CLA and agree to its terms |
For the reference, here's the linter output from a platform I've been testing on:
|
@sindhushiv, this PR introduces a new 3rd party dependency ( |
@defanator Could you please resolve conflicts? |
@jjngx sorry for slow response - I'll try to address this ASAP. |
@jjngx re #979 (comment), its Apache 2.0 👍🏼 |
test nginx conf:
start nginx docker container:
cURL:
stub_status:
exporter test with proxy_protocol:
exporter test without proxy_protocol:
exporter test with proxy_protocol using envvar PROXY_PROTOCOL:
|
I have verified the tests @vepatel ran |
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.
Pull Request Overview
This PR adds client-side support for proxy protocol v2 to the nginx-prometheus-exporter, enabling it to work with nginx instances behind load balancers that use proxy protocol. The implementation allows the exporter to send proxy protocol headers when connecting to nginx endpoints.
- Adds a new command-line flag
--nginx.proxy-protocol
to enable proxy protocol support - Implements proxy protocol v2 header generation and transmission for TCP and Unix socket connections
- Updates documentation to reflect the new functionality
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
go.mod | Adds dependency on github.com/pires/go-proxyproto v0.8.1 library |
exporter.go | Implements proxy protocol v2 client logic with connection wrapping and header transmission |
README.md | Documents the new --nginx.proxy-protocol command-line flag |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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:
proxy_protocol
, IPv4 withoutproxy_protocol
.proxy_protocol
, IPv6 withoutproxy_protocol
.proxy_protocol
, unix socket withoutproxy_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.