-
Notifications
You must be signed in to change notification settings - Fork 774
Get proxy protocol working correctly #404
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
Comments
hi, are you using externalTrafficPolicy to local ? (check the lb from traefik) fyi, you get 400 response when you setup proxy protocol only 1 side . (remember you need to add it at LB lvl + at your ingress level) |
Hi, when I check the Traefik LB it stated:
|
ok sorry, you dont try to get the real source ip , do you ? or you just want proxy protocol enable . |
No I actually do want the see client ip and not the ip's in between. |
could you describe the LB created to see if we have some annotation on your lb for the proxy protocol |
ok then if you need also to retrieve the real ip, you will need to be in local at least |
for your information i put a working example here, you can get some insights with it on OVH and adapt it to DO https://github.com/tanandy/helm-ovh-ingress/blob/main/ingress/traefik/values.yaml |
service.beta.kubernetes.io/do-loadbalancer-enable-proxy-protocol: "true" in your value as i did for ovh https://github.com/tanandy/helm-ovh-ingress/blob/main/ingress/traefik/values.yaml#L12 |
I tried to do the
But then only 1 node is healthy on the hw load balancer. Because it will not forward traffic to the other nodes. So I don't think that is the solution. What I did was adding this to the helm chart as extra answers:
This is what I will test atm, to see if it solves it. |
@tanandy thnx! |
you have 2 different things : 1/ you need to activate proxy protocol on ingress + lb (to support proxy protocol) 2/ you need to use externalTrafficPolicy local (to be able to retrieve real ip) |
Number 2 isn't needed, since it then breaks the LB. Edit i was to soon. The problem stil occurs :( |
really, i always needed to setup externaltrafficpolicy to local to get the real ip of the user. you may be lucky |
Well if I do that, 2 of the 3 nodes in the LB pool will show unhealthy. |
interesting, im not using DO. it could be useful to understand the reason. Maybe the difference between OVH & DO lbs |
Wel I think it might be due to the health checks. These are done on the node ports of the Traefik container on every node in the cluster. But if the health check doesn't reach the Traefik container (because of Anyway, iam not sure what can be done. Strange thing is that the same concept is working for NGINX. |
https://docs.digitalocean.com/products/kubernetes/how-to/configure-load-balancers/#proxy-protocol
If a service has a Cluster policy, requests will lose the original client IP address due to the extra network hop between the load balancer and the nodes. If your service requires retaining the requests original IP address, a Local policy is requires. |
you may need to customize healthcheck ?
|
haha I just wanted to paste the same link to the article! :) |
you can mitigate the traffic spread using pod anti affinity btw, its not perfect but its not that bad |
yes indeed, or it should be set to the kind DaemonSet maybe? But iam not sure if that's possible with this helm chart options. |
i dont see why using DaemonSet will resolve it ? |
A DaemonSet ensures that all (or some) Nodes run a copy of a Pod. So it will make sure every node has at least one Traefik container if I am right about this. https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/ So if every node has one Traefik pod and I set the |
ok,i was talking about the fact of not using externaltrafficpolicy local but cluster. i dont know about the daemonset, you could test im only using defaut chart currently that works for me but im not on DO. if you want to avoid using local and downside of this approach, you could mix proxy protocol + x forwarded for header (to preserve security) but you need one more mw to do the proxy protocol stuff |
@tanandy , how does that work? I don't think I quite understand. I tried to add the forwarded headers like adding:
But it does not seam to work in combination with It does work, when I add the actual external ip of the node to the array, but that's also not a solution on an elastic setup. The thing is that with the same setup and with DO loadbalancer + proxy protocol + NGINX it does work with: So NGINX uses the headers maybe differently then Traefik. |
i dont get your point . why are you trying to use forwarded headers ? are you trying to replace proxyprotocol by x forwaded for ?
you get the real ip with Cluster ? |
No I tried to add them both to see if it then will use the headers as client ip, but it doesn't matter. I was wondering why I do get it to work with NGINX on
So that makes me wonder if NGINX had implemented something so it will be able to pass the client ip. |
nginx + traefik support both forwarded headers + proxy protocol |
Yes, but on NGINX I do get it to work with Both have the DO LB annotation and Both have proxy protocol enabled. |
because you have to adapt traefik deployment to make DO hck works. i dont have time to dig into it, maybe you can try in that way ... i let you dig into it |
Yes, but with the Anyway thnx for your help! I will see if I can find a good solution. |
told you, you cant use externalTrafficPolicy: Cluster to get the real source ip afaik (for the reason above) |
Yes, I read the article, but didn't quite understand the proposed solution. |
the first mw will handle the proxy protocol part, then at your ingress lb you wont need proxy protocol but only forwarded headers to pass the real ip. (you cant rely only on forwarded headers since a header can be forge) |
I also tried to make it work, spent the day on it, and unfortunately it seems that it's a problem with Traefik itself cf traefik/traefik#8304 |
With some help from this thread and Traefik support, I was successful in getting proxy support to work with Digital Ocean while maintaining "externalTrafficPolicy: Cluster"; thus, working health checks for DigitalOcean load balancers. I'm using proxy support to apply ipwhitelist middlewares on my ingressroutes. For anyone else trying to do this, here are the changes I made to the helm values.
EDIT: I had some intermittent issues where the ipwhitelist middlewares would stop working when updated or after a couple hours of use. Using the whoami container, the headers consistently came through correctly from DO load balancers even when the ipwhitelist wasn't working. In my case, things became stable after I switched from having a separate ipwhitelist middleware for each my ingressroutes to using a single middleware shared across all of them. I also lowered the character count of my middlewares names from 25 to 17 characters. I can't imagine why either of these things would make a difference though. Hopefully it's just a fluke with my deployment. |
Additionally with @timothydlister's solution, I added a |
@timothydlister I have an almost identical setup to yours - DO Managed K8s running behind a DO LB with Traefik ingress, my config file is the same as yours, I have Do you have any idea what else might be missing from my setup? EDIT: I figured this out. I thought I was supposed to use the IP range of my DO VPC, however it turns out the Tip: You can view the |
Hello, It seems this issue is solved. |
Hi, |
Hello @badrdouah It's in the root section. |
@badrdouah You are editing a |
@mloiseleur i have tried the traefik forum , i got no help
then i applied the following values file
in the values file i replaced
with
since im using linode not digital ocean provider |
Using Kamal I got it working by entering the following:
|
Hi All,
I am trying to get proxy protocol enabled on my Traefik setup on DigitalOcean k8s.
The hw load balancer has proxy protocol. I can enable it manually, but then I get a error 400 respons from my ingressRoute.
I tried to add an additional argument to the entry point web with the trusted ip. I tried it with the internal subnet of DO and 127.0.0.1/32 like stated in the documentation. But on my 3 node cluster it sometimes gives the node ip of one of the 3 cluster nodes, instead of my ISP ip. I think this is because it is the node that Traefik container actual lives on.
I noticed that it only truly works when I add the additional argument like:
Any idea how to get proxy protocol working with the DO load balancer entry points, without getting the node ip?
The text was updated successfully, but these errors were encountered: