跳至正文
Wener Notes

Nginx Ingress 常见问题

约 1 分钟阅读
标签:FAQ

泛域名 Host 路由

yaml
annotations:
  # 只支持一条 rule - 可考虑拆分 ingress
  nginx.ingress.kubernetes.io/server-alias: '*.my-company.com'
  #ingress.kubernetes.io/server-alias: '*.my-company.com'

正则路径匹配

yaml
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: test-ingress
  annotations:
    nginx.ingress.kubernetes.io/use-regex: 'true'
spec:
  rules:
    - host: test.com
      http:
        paths:
          - path: /foo/.*
            backend:
              serviceName: test
              servicePort: 80

SSL Passthrough

  • 默认关闭 - --enable-ssl-passthrough
  • 通过拦截 443 端口到本地 TCP 代理, bypass NGINX, 性能影响很大
    • 本地代理端口 442
    • 如果 hostname 未被处理则又交由 NGINX 处理
  • 透传是发送到 service 而不是独立的 endpoint
  • - 可能开启了也不生效
yaml
# HELM values
controller:
  extraArgs:
    enable-ssl-passthrough: true

使用方式

yaml
annotations:
  nginx.ingress.kubernetes.io/ssl-passthrough: 'true'
  nginx.ingress.kubernetes.io/backend-protocol: 'HTTPS'
  kubernetes.io/ingress.allow-http: 'false'
  nginx.ingress.kubernetes.io/secure-backends: 'true'

HTTPS SNI 路由

yaml
# 相关配置
# https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#backend-certificate-authentication
annotations:
  # 修改 SNI
  nginx.ingress.kubernetes.io/proxy-ssl-name: wener.me
  nginx.ingress.kubernetes.io/proxy-ssl-protocols: HTTPS

关联信息

反向链接、本文链接的其他页面和外部资料。

参考资料

GitHub2 条
其他外链1 条
最近更新commit 1c2aff3编辑