• k8s 应用程序获取真实来源ip


    主要修改:nginx-configuration
    
     kubectl get   cm -n ingress-nginx    nginx-configuration      -o yaml
    apiVersion: v1
    data:
      log-format-upstream: '{ "time": "$time_iso8601", "remote_addr": "$proxy_protocol_addr","x-forward-for":
        "$proxy_add_x_forwarded_for", "request_id": "$req_id", "remote_user":"$remote_user",
        "bytes_sent": $bytes_sent, "request_time": $request_time, "status":$status, "vhost":
        "$host", "request_proto": "$server_protocol", "path": "$uri","request_query":
        "$args", "request_length": $request_length, "duration": $request_time,"method":
        "$request_method", "http_referrer": "$http_referer", "http_user_agent":"$http_user_agent"
        }'
      use-forwarded-headers: "true"
    kind: ConfigMap
    metadata:
      annotations:
        kubectl.kubernetes.io/last-applied-configuration: |
          {"apiVersion":"v1","kind":"ConfigMap","metadata":{"annotations":{},"labels":{"app.kubernetes.io/name":"ingress-nginx","app.kubernetes.io/part-of":"ingress-nginx"},"name":"nginx-configuration","namespace":"ingress-nginx"}}
      creationTimestamp: "2020-08-03T04:49:35Z"
      labels:
        app.kubernetes.io/name: ingress-nginx
        app.kubernetes.io/part-of: ingress-nginx
      name: nginx-configuration
      namespace: ingress-nginx
      resourceVersion: "35168897"
      selfLink: /api/v1/namespaces/ingress-nginx/configmaps/nginx-configuration
      uid: 824c5020-5a65-44aa-9dd8-0b71070ce68e
    
    
    配置文件增加的内容为:
    data:
      log-format-upstream: '{ "time": "$time_iso8601", "remote_addr": "$proxy_protocol_addr","x-forward-for":
        "$proxy_add_x_forwarded_for", "request_id": "$req_id", "remote_user":"$remote_user",
        "bytes_sent": $bytes_sent, "request_time": $request_time, "status":$status, "vhost":
        "$host", "request_proto": "$server_protocol", "path": "$uri","request_query":
        "$args", "request_length": $request_length, "duration": $request_time,"method":
        "$request_method", "http_referrer": "$http_referer", "http_user_agent":"$http_user_agent"
        }'
      use-forwarded-headers: "true"
    

      

  • 相关阅读:
    SVN的使用
    ajax 显示,删除,批量删除,修改反填功能实现
    Linux 安装软件的几种方式
    《面向对象软件开发实践》笔记一
    Entity Framework 新手入门友好实例
    MIT 计算机科学及编程导论 Python 笔记 1
    JetBrains套装免费学生授权申请(IntelliJ, WebStorm...)
    我的十月
    关于《未成年人网络保护条例(草案征求意见稿)》的意见
    C# 分隔字符串成为字符串数组的方法(保留分隔符)
  • 原文地址:https://www.cnblogs.com/lixinliang/p/13926049.html
Copyright © 2020-2023  润新知