如何给 K8S Nginx Ingress 添加 proxy_set_header 配置

2020-01-29 19:56发布

问题:

在 Kubernetes 集群上部署了 Nginx Ingress Controller ,请问如何如何给 Nginx 添加下面的配置?

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;

回答1:

可以通过 ingress 的 nginx.org/location-snippets 注解添加

apiVersion: extensions/v1beta1 
kind: Ingress
metadata:
  name: cnblogs-ingress
  annotations:
    nginx.org/location-snippets: |
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection $connection_upgrade;


标签: k8s nginx