Skip to content

LoadBalancer Services cannot discover the true ClientIP #74

Closed

Description

@asauber

X-Forwarded-For, X-Real-IP, ProxyProtocol and friends currently see only an IP in the range 192.168.255.0/24

Activity

  1. asauber commented on Jul 27, 2020

    @asauber
    ContributorAuthor

    Yes, thank you for your comment. 😄

    ProxyProtocol support is coming soon to Linode NodeBalancers, which will allow all of these use cases either directly at the TCP level or beyond the Ingress controller. 🚀

  2. mortenbirkelund commented on Aug 25, 2020

    @mortenbirkelund

    @asauber any news or time-line for when this will be supported? Thanks

  3. asauber commented on Aug 27, 2020

    @asauber
    ContributorAuthor

    Hi @mortenbirkelund! Proxy Protocol support was very recently added to NodeBalancers, so the next step is to add a Service annotation to this codebase that will allow enabling it. We don't have a specific timeline for this implementation at the moment. I will update this issue as soon as there is a PR or other progress on that.

  4. laszlocph commented on Sep 24, 2020

    @laszlocph

    🎉

  5. asauber commented on Sep 25, 2020

    @asauber
    ContributorAuthor

    All LKE clusters will be upgraded to use this version of the CCM within the next two weeks.

  6. mortenbirkelund commented on Sep 27, 2020

    @mortenbirkelund

    @asauber great news. Thanks for the update

  7. carminalazu commented on Oct 5, 2020

    @carminalazu

    Is there anything else that we need to do to benefit from this other than thechangelog/changelog.com@a29bee7 & then just waiting for this to be rolled out across Node Balancers?

  8. asauber commented on Oct 5, 2020

    @asauber
    ContributorAuthor

    @carminalazu In the manifest that you linked, you're placing the annotation on an Ingress resource. However, this annotation is used by Service resources. In your case, it would be the Service that sits in front of ingress-nginx.

    Once you've enabled Proxy Protocol for ingress-nginx, it looks like you would also need to set this setting in the ingress-nginx ConfigMap https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#use-proxy-protocol

  9. carminalazu commented on Oct 6, 2020

    @carminalazu

    I was assuming that this feature will make the X-Forwarded-For, X-Real-IP headers work as expected, which is what this captured:

    https://github.com/thechangelog/changelog.com/blob/0e4e5831f494129d0697e34a54a5673e58c4491d/k8s/ingress-nginx/configmap.yml#L8-L12

    The nginx-ingress docs explain that the Proxy protocol is a different approach:

    Another option is to enable proxy protocol using use-proxy-protocol: "true".
    In this mode NGINX does not use the content of the header to get the source IP address of the connection.

    This is the ingress-nginx config update that we should end up with:

    -use-forwarded-headers: "true"
    -
    -# TODO: https://github.com/linode/linode-cloud-controller-manager/issues/74
    +use-proxy-protocol: "true"
    enable-real-ip: "true"
    proxy-real-ip-cidr: "192.168.255.0/24"

    If I understand you correctly, the annotation needs to be put on this service. Is that right?

    https://github.com/kubernetes/ingress-nginx/blob/274d09447e4735815846985c3133bbdc3f00a942/deploy/static/provider/cloud/deploy.yaml#L273-L301

    One last question: what happens if the PROXY protocol is enabled on the nginx ingress, but the node balancers don't have this capability rolled out?

  10. asauber commented on Oct 8, 2020

    @asauber
    ContributorAuthor

    This feature adds an annotation for LoadBalancer Services which enables Proxy Protocol on the associated NodeBalancers. This means that an Ingress controller that supports Proxy Protocol, like nginx-ingress, can then provide X-Forwarded-For headers to its backends.

    Yes, you would need to modify that Service resource to add the annotation service.beta.kubernetes.io/linode-loadbalancer-proxy-protocol: "v2" Also, your diff looks correct, which disables header forwarding and enables Proxy Protocol.

    To answer your last question. I'm happy to report that as of October 2nd all Linode NodeBalancers and LKE clusters support these features!

  11. asauber commented on Oct 8, 2020

    @asauber
    ContributorAuthor
  12. mortenbirkelund commented on Oct 14, 2020

    @mortenbirkelund

    @asauber After enabling proxy, I am having some problems. I have a registy hosted on the same kubernetes cluster, and after enabling proxy protocol, it is no longer possible to pull images from the registry.

    When looking into the Ingress-controller pod I see the following errors when trying to pull an image.

    I have anonymized the domain and the ip

    2020/10/14 09:41:40 [error] 7943#7943: *27088288 broken header: "�������P+"/J	i]Kp{=�-�(�T��b۬6�,�0�+�/�
    �	��Xmy.registy.domain.com
    
    " while reading PROXY protocol, client: 11.1.111.11, server: 0.0.0.0:443
    2020/10/14 09:41:53 [error] 7943#7943: *27088369 broken header: "����t�yfh�!1ϓI�W6�g����o�֏�,�0�+�/�
    �	��Xmy.registy.domain.com
    
    " while reading PROXY protocol, client: 11.1.111.11, server: 0.0.0.0:443
    2020/10/14 09:42:18 [error] 7943#7943: *27088525 broken header: "����g���5ِf�}EmY/�x2VO�^��,�0�+�/�
    �	��Xmy.registy.domain.com
    
    " while reading PROXY protocol, client: 11.1.111.11, server: 0.0.0.0:443
    2020/10/14 09:43:02 [error] 7943#7943: *27088799 broken header: "���<��qʃ�����Q0��eX��O�zt���X�,�0�+�/�
    �	��Xmy.registy.domain.com
    
    " while reading PROXY protocol, client: 11.1.111.11, server: 0.0.0.0:443
    2020/10/14 09:44:36 [error] 7942#7942: *27089382 broken header: "��y�&���{��p��Z���0MxɠS��H�h�D�,�0�+�/�
    �	��Xmy.registy.domain.com
    

    As soon as I disable proxy protocol in the ingress controller, everything works fine.

  13. 9 remaining items

  14. mortenbirkelund commented on Oct 25, 2020

    @mortenbirkelund

    @asauber thanks for the good explanation

    It seems like my docker registry doesn't allow setting multiple hostname (I am using harbor) goharbor/harbor#8243

    So I guess I will either have to move my registry to a separate cluster or hope that you will implement a fix as suggested by @laszlocph

  15. jittuu commented on Oct 29, 2020

    @jittuu

    I am now facing the cert-manager issue. The challenge is failed if Proxy Protocol is enabled.

    I guess I have to wait for a while to use proxy protocol.

  16. asauber commented on Nov 3, 2020

    @asauber
    ContributorAuthor

    Hi. A quick update for this issue. We have decided to implement the hostname-based fix for this within the coming weeks.

    In the mean time, users have reported success using this controller-based solution https://github.com/compumike/hairpin-proxy

  17. mortenbirkelund commented on Dec 30, 2020

    @mortenbirkelund

    @asauber any idea when this will be implemented. I see there is an open pull request for it.

  18. sibucan commented on Dec 30, 2020

    @sibucan
    Contributor

    @mortenbirkelund Hi there! Once the the PR is merged and a new CCM release is made with those changes, an LKE update will follow that will include an update to the CCM to the latest released version. We will ensure that when the update is available, the LKE changelog will reflect the CCM version being used. Thanks!

  19. mortenbirkelund commented on Jun 28, 2021

    @mortenbirkelund

    Tried to use the newly added annotation service.beta.kubernetes.io/linode-loadbalancer-hostname-only-ingress: "true" but it doesnt seem to work. cert-manager is still failing because of self-check not going through.

    https://github.com/compumike/hairpin-proxy however did solve the problem.

  20. calbot commented on Dec 30, 2021

    @calbot

    I'm still very confused. Is this truly fixed?
    Is there some documentation for the correct encantations to get X-Forwarded-For to send the client IP when using helm to install the nginx ingress controller?

    helm upgrade --install ingress-nginx -f helm/inginx-ingress/customvalues.yaml ingress-nginx/ingress-nginx

    my customvalues.yaml file:

    controller:
      service:
        annotations:
          service.beta.kubernetes.io/do-loadbalancer-enable-proxy-protocol: "true"
      config:
        use-forwarded-headers: "true"
        enable-real-ip: "true"
        proxy-real-ip-cidr: "192.168.255.0/24"
    

    Can the documentation here https://www.linode.com/docs/guides/how-to-deploy-nginx-ingress-on-linode-kubernetes-engine/
    be updated so that X-Forwarded-For is properly set?

    I see this page https://www.linode.com/docs/guides/nodebalancer-reference-guide/ says
    nginx should have the following settings

    real_ip_header X-Forwarded-For;
    set_real_ip_from 192.168.255.0/24;
    
    

    Mine also has real_ip_recursive on; coming from the helm template. Would that be the source of the problem?

  21. calbot commented on Dec 30, 2021

    @calbot

    I was able to figure it out. If anyone else is using the helm chart instructions (from https://www.linode.com/docs/guides/how-to-deploy-nginx-ingress-on-linode-kubernetes-engine/) you can do the following...
    Log into the linode console > Nodebalancers > instanceID > configuration > 443/80 > Port Configuration > Proxy Protocol. I selected v2

    Installing the helm chart below automatically creates the node balancer but doesn't setup the proxy protocol as above (for me at least).

    The following configuration for the helm chart worked for me:
    helm upgrade --install ingress-nginx -f helm/inginx-ingress/customvalues.yaml ingress-nginx/ingress-nginx

    customvalues.yaml

    controller:
      service:
        annotations:
          service.beta.kubernetes.io/do-loadbalancer-enable-proxy-protocol: "true"
          service.beta.kubernetes.io/linode-loadbalancer-proxy-protocol: "v2"
      config:
        use-proxy-protocol: "true"    
        use-forwarded-headers: "true"
    

    After that the X-Forwarded-For was sent to my app

  22. badrdouah commented on Nov 27, 2022

    @badrdouah

    service.beta.kubernetes.io/do-loadbalancer-enable-proxy-protocol: "true"

    i think you mean

    service.beta.kubernetes.io/linode-loadbalancer-enable-proxy-protocol: "true"

    "do" stands for digital ocean, this line in not nessecary, the second one will do the job i guess

  23. LukasBlu1 commented on May 2, 2023

    @LukasBlu1

    Hi all! Is this also working with nodejs, in case yes, is there someone who has a tutorial for this? Thanks in advance :)

  24. Kliprmimo commented on Nov 12, 2025

    @Kliprmimo

    Hey, i tried running cert manager ith this settings in ingress nginx:

    service.beta.kubernetes.io/linode-loadbalancer-proxy-protocol: "v2"
    use-proxy-protocol: "true"    
    use-forwarded-headers: "true"
    

    I run into the issue discussed earlier:
    broken header: "GET /.well-known/acme-challenge/xxx HTTP/1.1" while reading PROXY protocol

    Is there a known "non-hacky" or recommended way to properly handle the PROXY protocol for HTTP-01 ACME challenges with cert-manager and ingress nginx?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions