我需要帮助为不同后端中的两个服务设置TLS终止(使用ingress-nginx)。
https://some.url.here/serviceOne/ -> http://hostOne/
https://some.url.here/serviceTwo/ -> http://hostTwo/someServiceNameHere/
我试着用rewrite-target: "/"
、rewrite-target: "/$1"
和use-regexp: "true"
做这件事,但是连接到http://hostTwo/someServiceNameHere/
总是失败。
我的入口定义如下:
kind: Ingress
metadata:
name: rp-some-url-here
namespace: reverse-proxy
annotations:
kubernetes.io/ingress.class: nginx
# ??? nginx.ingress.kubernetes.io/rewrite-target: "/$1"
# ??? nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
nginx.ingress.kubernetes.io/proxy-ssl-verify: "false"
nginx.ingress.kubernetes.io/upstream-vhost: "some.url.here"
nginx.ingress.kubernetes.io/proxy-connect-timeout: "600"
nginx.ingress.kubernetes.io/proxy-send-timeout: "600"
nginx.ingress.kubernetes.io/proxy-read-timeout: "600"
# proxy-buffering is now disabled by default,
# just having it here for reference
nginx.ingress.kubernetes.io/proxy-buffering: "off"
spec:
tls:
- hosts:
- some.url.here
secretName: my-tls-secret
rules:
- host: some-url-here
http:
paths:
- backend:
service:
name: serviceOne
port:
number: 80
# path: /serviceOne # using this with rewrite-target
path: /serviceOne/.*
pathType: Prefix
- backend:
service:
name: serviceTwo
port:
number: 8180
# path: /serviceTwo # using this with rewrite-target
path: /serviceTwo/.*
pathType: Prefix
服务定义就像
---
apiVersion: v1
kind: Service
metadata:
name: service-one
namespace: reverse-proxy
spec:
type: ExternalName
externalName: some.hostname.here
---
apiVersion: v1
kind: Service
metadata:
name: service-two
namespace: reverse-proxy
spec:
type: ExternalName
externalName: another.hostname.here
1条答案
按热度按时间gopyfrb31#
下面是一个快速示例,说明应该如何完成,同时确保您的第二个服务响应您指定的端口(8180)