我已经尝试了栈溢出及其他方面的一切,但找不到一个能将http重定向到https的解决方案。我当前的配置如下。
我的入口是:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress
annotations:
kubernetes.io/ingress.class: "nginx"
kubernetes.io/ingress.global-static-ip-name: my-address
networking.gke.io/managed-certificates: my-certificate
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
nginx.ingress.kubernetes.io/from-to-www-redirect: "true"
spec:
rules:
- host: mydomain.com
http:
paths:
- path: /*
pathType: ImplementationSpecific
backend:
service:
name: my-service
port:
number: 2400
我的服务是:
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
type: NodePort
selector:
app: nodeweb
ports:
- name: my-service-port
protocol: TCP
port: 2400
targetPort: 2400
对于GKE(1.17.13-gke.2600+
(,请参阅本文档,解释如何使用http到https重定向配置FrontendConfig。然后使用networking.gke.io/v1beta1.FrontendConfig
注释将FrontendConfig与Ingress关联起来。