Skip to content

enable-real-ip with custom header does not take effect if using use-proxy-protocol #13373

Closed
@krogon

Description

@krogon

What happened:

enable-real-ip with custom forwarded-for-header does not take effect if using use-proxy-protocol

real_ip_header nginx param is always set to proxy_protocol which requires workaround of using server-snippet to explicitly overwrite that.

What you expected to happen:
I wish being able to configure real_ip_header without the need to enable allowSnippetAnnotations.

What do you think went wrong?:
https://github.com/kubernetes/ingress-nginx/blob/ingress-nginx-3.15.2/rootfs/etc/nginx/template/nginx.tmpl#L135-L140

    {{ if or (or $cfg.UseForwardedHeaders $cfg.UseProxyProtocol) $cfg.EnableRealIp }}
    {{ if $cfg.UseProxyProtocol }}
    real_ip_header      proxy_protocol;
    {{ else }}
    real_ip_header      {{ $cfg.ForwardedForHeader }};
    {{ end }}

nginx.conf would be generated as:

real_ip_header      proxy_protocol;

instead of

real_ip_header      CF-Connecting-IP;

How to reproduce this issue:

Use following config

use-proxy-protocol: "true"
proxy-real-ip-cidr: "0.0.0.0/0"
use-forwarded-headers: "true"
enable-real-ip: "true"
forwarded-for-header: "CF-Connecting-IP"

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.needs-priorityneeds-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions