vua*_*tom 5 kubernetes-ingress nginx-ingress
我正在配置入口以根据路径将请求传递到后端。只service-external需要使用 HTTPS。如果我添加注释nginx.ingress.kubernetes.io/backend-protocol: 'HTTPS',入口将为两个后端使用 https,这是不希望的。有没有办法仅对选定的后端使用 https?
ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/ssl-redirect: 'true'
tls:
- secretName: my-tls
hosts:
- myhost.com
rules:
- host: myhost.com
paths:
- path: /external/
serviceName: service-external
servicePort: 443
- path: /
serviceName: service-api
Run Code Online (Sandbox Code Playgroud)
正如评论中提到的,在入口规范中使用注释将为所有路径启用此功能。
实现您想要的唯一方法是创建一个具有所需路径的新入口规范。因此,您将有 2 个相同的入口host,请参阅此示例:
我正在配置入口以根据路径将请求传递到后端。只 service-external 需要使用 HTTPS。如果我添加注释 nginx.ingress.kubernetes.io/backend-protocol: 'HTTPS',入口将为两个后端使用 https,这是不希望的。有没有办法仅对选定的后端使用 https?
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-https-ingress
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
spec:
tls:
- hosts:
- myapp.com
secretName: myapp.com
rules:
- host: myapp.com
http:
paths:
- path: "/"
backend:
serviceName: my-https-service
servicePort: 443
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-http-ingress
annotations:
kubernetes.io/ingress.class: nginx
spec:
tls:
- hosts:
- myapp.com
secretName: myapp.com
rules:
- host: myapp.com
http:
paths:
- path: "/notsecure"
backend:
serviceName: my-http-service
servicePort: 80
Run Code Online (Sandbox Code Playgroud)
第一个入口将重定向每个请求https://myapp.com/to my-https-service,如果请求是 to ,https://myapp.com/notsecure则请求将通过 HTTP 重定向到服务my-http-service,但对于最终用户来说,连接仍然是HTTPS。
| 归档时间: |
|
| 查看次数: |
4674 次 |
| 最近记录: |