<p>How get client IP from nginx ingress load blanacer? I've tried setting <code>use proxy protocol</code> and <code>externalTrafficPolicy</code> but still it doesn't show client IP.</p>
<p>Apache logs <code>10.0.0.225</code> for each http request. I'm not sure what IP that is, it doesn't seem to be pod's
IP or node IP.</p>
<p>httpd service:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: httpd
  labels:
    app: httpd-service
  namespace: test-web-dev
spec:
  type: NodePort
  selector:
    app: httpd
  ports:
    - name: port-80
      port: 80
      protocol: TCP
      targetPort: 80
    - name: port-443
      port: 443
      protocol: TCP
      targetPort: 443
  sessionAffinity: &quot;ClientIP&quot;
  sessionAffinityConfig:
    clientIP:
      timeoutSeconds: 10800
  externalTrafficPolicy: Local
</code></pre>
<p>ingress-lb:</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: tcp-services
  namespace: ingress-nginx
data:
  use-proxy-protocol: 'true'
---
kind: Service
apiVersion: v1
metadata:
  name: ingress-nginx
  namespace: ingress-nginx
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
spec:
  externalTrafficPolicy: Local
  type: LoadBalancer
  selector:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
  ports:
    - name: http
      port: 80
      protocol: TCP
      targetPort: http
    - name: https
      port: 443
      protocol: TCP
      targetPort: https
</code></pre>
<p>In Apache I've  configured the following logging settings:</p>
<pre><code>LogFormat &quot;%{X-Forwarded-For}i %l %u %t \&quot;%r\&quot; %&gt;s %b \&quot;%{Referer}i\&quot; \&quot;%{User-Agent}i\&quot;&quot; combined
LogFormat &quot;%h %l %u %t \&quot;%r\&quot; %&gt;s %b \&quot;%{Referer}i\&quot; \&quot;%{User-Agent}i\&quot;&quot; combined
LogFormat &quot;%{X-Forwarded-For}i %l %u %t \&quot;%r\&quot; %&gt;s %b \&quot;%{Referer}i\&quot; \&quot;%{User-Agent}i\&quot;&quot; proxy
SetEnvIf X-Forwarded-For &quot;^.*\..*\..*\..*&quot; forwarded
CustomLog &quot;logs/ssl_access_log&quot; combined env=!forwarded
CustomLog &quot;logs/ssl_access_log&quot; proxy env=forwarded
</code></pre>

<p>You should get the origin IP in the <code>X-Forwarded-For</code> header, this is a default config for nginx-ingress: <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#forwarded-for-header" rel="nofollow noreferrer">forwarded-for-header</a></p>
<p>This is configured in a <a href="https://kubernetes.github.io/ingress-nginx/examples/customization/custom-configuration/" rel="nofollow noreferrer">ConfigMap</a></p>
