1、访问k8s服务里面的前端内容时,需要经过ingress再到前端的nginx,所以有些nginx参数不止要在前端nginx配置,还要在ingress添加配置才能生效。之前在配置underscores_in_headers on参数时就是在ingress增加了enable-underscores-in-headers: "true"才生效

2、 ingress-nginx 的 ConfiMap 添加 参数配置,按自己的需求添加

kind: ConfigMap
apiVersion: v1
metadata:
  name: nginx-configuration
  namespace: ingress-nginx
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
data:
  enable-underscores-in-headers: "true"
  allow-backend-server-header: "true"
  http-redirect-code: "301"
  reuse-port: "true"
  upstream-keepalive-timeout: "900"
  proxy-body-size: "20m"
  log-format-upstream: >-
    $remote_addr - [$remote_addr] - $remote_user [$time_local] "$request"
    $status $body_bytes_sent "$http_referer" "$http_user_agent" $request_length
    $request_time [$proxy_upstream_name] $upstream_addr
    $upstream_response_length $upstream_response_time $upstream_status $req_id
    $host [$proxy_alternative_upstream_name]
  proxy-connect-timeout: "10"
  ssl-redirect: "false"
  worker-cpu-affinity: "auto"
  server-tokens: "false"
  generate-request-id: "true"
  max-worker-connections: "65536"

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐