-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Support HAProxy Protocol (equivalent to curl --haproxy-protocol option) #2510
Comments
Hmm, yeah, this seems difficult to fit in an extensions, it might be something more suitable for #2461 Though I am confused. Why should k6 send this data, in a |
Given that the proxy server ONLY understands the proxy-protocol, the client has to write the PROXY protocol headers on the connection first. Similar option '--haproxy-protocol' was implemented in the 'curl' utility (which is a client). See curl/curl@6baeb6d. In order to test such a proxy server using k6, the k6 http client needs to write those proxy headers on the connection to the proxy server. |
Ah, I think I see, this comment from the curl commit you linked cleared up my confusion:
Please tell me if I've understood things correctly. If your normal production setup is Is that a fair explanation? |
Yes, almost. Except that in my use case, the 'proxy server' application is a multi-tenant proxy that is responsible for authN, then redirects the original request to tenant owned applications. In this case, the tenant applications DO NOT speak proxy protocol. However, my multi-tenant proxy mandates proxy protocol as the only option from north clients. Ofcourse my proxy application is also to be front-ended by another 'thing' that knows how to send proxy protocol headers to my proxy application. However, I intend to test my application with k6 and not the one that is in front of my proxy application. As a matter of fact, I would not care about any service chains created above my application. Hope this makes sense. |
I see, thanks for explaining! When it comes to how this can be implemented in k6, I don't have time to look into all of the details, but from what I can see in your diff above, it might be possible to implement this with a simple xk6 JS extension as the first step 🤔 You have basically slightly modified the Lines 84 to 93 in ff4c8fb
Lines 258 to 262 in ff4c8fb
Line 56 in ff4c8fb
So, basically, a JS extension should be able to wrap and replace the VU In the long run, this may possibly be a built-in part of the k6 core, but we probably won't include it as is in the current For example, I can imagine a valid use case where you'd want only specific HTTP requests (or requests with other protocols) to use this PROXY protocol, while others (e.g. to a separate endpoint of your app) need to be without it. Since the |
Ok. The reason I tried to introduced a defined header (per request), was to allow for different request types (one using PROXY protocol, others may not include the header). Anyways, will see how it can be built as an extension. Thank you for your response. |
As @na-- mentioned, we're unlikely to support this in the current HTTP API, but will consider it as part of the new API (initial design document), which we're starting to work on now. We're still ironing out the design and syntax, so feel free to follow the issue and document for details. I'll close this in the meantime, as we'd like to work with a clear roadmap. |
Feature Description
Need the ability to load test an application that speaks proxy protocol at its core (e.g. envoy proxy application). In order to test such endpoints, the k6 http module must write PROXY headers immediately after dialing the connection. Here is an example - https://blog.rajatjindal.com/post/golang-proxy-protocol-http-client/ that demonstrate how to write PROXY headers on a connection.
k6 recommends building custom extensions (modules) for such things. However, this requirement applies to the core of HTTP module shipped by k6, and building an extension will require a lot of work.
The feature request here is to support proxy protocol in the core of k6 HTTP module.
Suggested Solution (optional)
It may not be ideal to use a custom header in order to support proxy-protocol. However, thats the easiest I could think of (an alternative could be a custom tags). Also, note that context object is added with additional KV for the dialer to know when to write the PROXY headers on connection.
Example Patch to k6 http module
An example test may look like (note the special header 'X-HAProxy-Protocol') -
Already existing or connected issues / PRs (optional)
No response
The text was updated successfully, but these errors were encountered: