helm安装ingress-nginx开启自定义header以及关闭强制https跳转
介绍
默认安装的ingress-nginx,是没有开启用户自定义header的,以及强制跳转https是开启的,所以我们可以选择关闭。
配置
修改values.yaml文件,配置如下:
1 2 3 4 5
| config: allow-backend-server-header: "true" enable-underscores-in-headers: "true" hsts-include-subdomains: "false" ssl-redirect: "false"
|
修改完成后升级ingress-nginx,查看默认ingress-controller启动配置的configmap,配置中多了一些自定义内容。
1 2 3 4
| [root@locahost]# kubectl get configmap -n ingress NAME DATA AGE ingress-controller-leader-ingress-public-eve 0 9d ingress-nginx-controller 1 9d
|
查看ingress-nginx-controller可以获取到自定义的配置:
1 2 3 4 5 6 7 8 9
| apiVersion: v1 data: allow-backend-server-header: "true" enable-underscores-in-headers: "true" hsts-include-subdomains: "false" ssl-redirect: "false" kind: ConfigMap ... ...
|
另外说一句
因为上述我们关闭了全局的默认强制跳转https,如果有需要强制跳转,我们可以单独配置在ingress资源上,如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| apiVersion: extensions/v1beta1 kind: Ingress metadata: annotations: kubernetes.io/ingress.class: ingress-public nginx.ingress.kubernetes.io/force-ssl-redirect: "true" name: ingress-prexx-xx-com namespace: eve spec: rules: - host: prexx.xx.com http: paths: - backend: serviceName: php-global-svc-pre servicePort: 80 tls: - hosts: - prexx.xx.com secretName: x-xx-com-20200728
|