-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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 Host header in HTTP health checks #2657
Conversation
This commit introduce support for passing Host HTTP Header in HTTP health checks. Such check pattern is very common (for ex. when using a reverse-proxy) and you usually want to check the user facing port/API rather than the internal service exposed to 127.0.0.1. Fix hashicorp#1184
Does not fix #1184 actually, but one use case only (Host header)... I can edit my commit message if needed. |
This PR is very similar to #2474 (and I'd be happy if both could be merged) |
I would say that this commit is useful not only for reverse-proxy. We need some analog of curl's --resolve option. And I hope that this commit is what we need. |
Hello @slackpad, would you have any feedback regarding this PR? |
@slackpad - this would really help us with the resiliency of our service proxy setup & consul. |
This is huge for us. We are using Linkerd and the only thing that differentiates our services is the Host header. |
Why can't you just use the correct host name in the check URL? |
@magiconair : imagine the following setup:
So here the goal of the Consul health check is to reflect the LOCAL state and not the global one which will be given to the end-user by Consul itself (DNS API for ex.). In this case when a request To check that my local service is OK, but using the exact same endpoint than my end-user I have to pass the Host header to the reverse proxy. |
@magiconair we are using a Linkerd mesh network, which will proxy and route communication to the correct service. Creating DNS entries for every service pointing to the same Linkerd entrypoint would defeat the purpose of using Linkerd. Since, all requests are made to the entrypoint and then routed by either by Host or linkerd-specific HTTP header, if we could specify a header, we could test our Linkerd routing to ensure it's configured properly. Not being able to assign a header means we have to dump a lot of effort into finding other solutions for testing the health of these endpoints through the proxy (like extend the Consul Docker container or create a sidecar container that performs health checks and reports them to Consul). |
I'm not against adding headers to the health checks but I'd like to understand the actual use-case first. Second, if we're going to add this then we should have some more generic header and method configuration and combine this ideally with #2474 in a single PR. Just adding the host header is too narrow in scope IMO since then people will probably want to add headers for all kinds of things, e.g. auth, tracing, logging, ... Also, since I'm still maintaining https://github.com/fabiolb/fabio I've got some experience with reverse proxy setups. :) From what I understand your setup is the following:
What I'm also reading is that you register What I'm also reading is that if you register Is this a correct description of your setup/problem? Assuming this is correct, I see two things here:
What am I missing? |
The only thing you're missing here is that we register in Consul what's already accessible to the end-user, meaning Now you have 2 choices for the health-check:
As stated in my first comment, I completely agree that something more generic could be even better. Host is one use-case, probably the more common, but there are definitely others. |
@pierrecdn I'm sorry if I'm a bit dense but what is
In that case only the L7 router needs the host name for routing unless you need to spoof it for the service the L7 router sends the request to (e.g. |
@magiconair I like being able to generically set headers (no need for specific headers); this will solve our use case. What we are trying to achieve specifically is a way to make sure the dynamic routing configuration in Linkerd is correct by checking for those services through the network fabric. These services are not user facing. We have a an external Linkerd interface that routes public traffic to our Gateway microservice. The Gateway microservice calls/forwards/proxies requests to the appropriate downstream microservice through an internal Linkerd interface. So it looks something like: Amazon ALB -> Linkerd External Interface -> Gateway -> Linkerd Internal Interface -> Downstream Service We dynamically create network meshes with our CI/CD system upon a successful integration test run. The network mesh provides "virtual" addresses for services registered in Consul. For instance, we will deploy as service with the name What I want to do is create health checks for the virtual mappings. Specifically, I want to know if a particular network mesh have nodes that are inaccessible through the Linkerd Internal Interface. I will already know if the service is working via a standard Consul health check. I just want to further make sure that my routing infrastructure is also configured correctly. I hope that better describes our use case. |
@magiconair I wasn't clear enough in my explanation apparently. So, instance:80 doesn't exists in reality but this is what the end user cares about. In fact the real service is bound to The "L7 router" listen on 80 and forwards to it based on the Host header. Here it supposes that the end-user will uses the DNS (A) API. So I agree with "only the L7 router needs the host name for routing". And as the health-check is performed through the L7 router, I needed Host header support into Consul health-checks. |
@pierrecdn If you perform the health check through the L7 router you only need to use the correct URL IMO, e.g. I've opened #3106 to track this. |
@magiconair yes, but what happen if this URL is |
@pierrecdn Thanks for your patience in this discussion :) I think this argument doesn't hold since adding the In any case, I've taken your PR and augmented it so that you can set any header and any method since I think this a good addition in any case. Feel free to test #3106 since I still need to add some more tests and update the docs. I will credit both you and the author of #2474 in the commit since both of you have done the original work. I should be able to get this into the 0.8.4 release. |
I need to spoof the header. If not I may not test the local service but one on the network. |
will use the new feature in 0.8.4 thanks! |
This commit introduce support for passing Host HTTP Header in HTTP health
checks.
Such check pattern is very common (for ex. when using a reverse-proxy) and
you usually want to check the user facing port/API rather than the
internal service exposed to 127.0.0.1.
Fix #1184