Arc*_*nic 7 ssl kubernetes google-kubernetes-engine ingress
我有一个基本的 nginx 部署和一个由 let's 通过 cert-manager 加密颁发的现有证书。我以为一切都已准备就绪,可以开始使用证书,但我无法连接 https。
连接到 LoadBalancer IP 和域可以正常工作。使用 https 连接域无法连接。Chrome 这么说ERR_SSL_PROTOCOL_ERROR,Firefox 这么说SSL_ERROR_RX_RECORD_TOO_LONG,SSL Labs 这么说Assessment failed: No secure protocols supported。都是同一个问题。
这是服务:
apiVersion: v1
kind: Service
metadata:
name: nginx
namespace: example
labels:
app: example
spec:
type: LoadBalancer
ports:
- name: http
protocol: TCP
port: 80
targetPort: 80
- name: https
protocol: TCP
port: 443
targetPort: 80
selector:
app: example
Run Code Online (Sandbox Code Playgroud)
这是入口:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: nginx
namespace: example
annotations:
cert-manager.io/cluster-issuer: letsencrypt-production
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/ssl-passthrough: "true"
spec:
tls:
- hosts:
- 'example.com'
secretName: example-production-tls
rules:
- host: example.com
http:
paths:
- path: /
backend:
serviceName: nginx
servicePort: 443
Run Code Online (Sandbox Code Playgroud)
证书已填充:
kubectl describe secret
...
Data
====
tls.crt: 3574 bytes
tls.key: 1675 bytes
ca.crt: 0 bytes
Run Code Online (Sandbox Code Playgroud)
并且证书资源归正确的入口所有。我已将我的域名替换为上面的“示例”。
似乎一切都已就绪,但我不确定为什么无法通过 https 连接。我可以运行什么来解决这个问题?
更新:我发现我的部署和 nginx 映像缺少一些配置。我已执行此处的所有步骤:https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/#secure-the-service
和以前一样,我可以连接到 443 和 80 上的 LoadBalancer IP,但 https 连接失败。使用http:
curl http://<EXTERNAL-IP> -k
<html>
<h1>Hello!</h1>
<p>Stay tuned for launch!</p>
</html>
Run Code Online (Sandbox Code Playgroud)
https 失败:
curl https://<EXTERNAL-IP> -k
curl: (35) error:1400410B:SSL routines:CONNECT_CR_SRVR_HELLO:wrong version number
Run Code Online (Sandbox Code Playgroud)
本例中的问题是部署和服务的组合。我使用服务 yaml 中的这一行将 https 流量路由到端口 80:
- name: https
protocol: TCP
port: 443
targetPort: 80
Run Code Online (Sandbox Code Playgroud)
这无法完成 SSL 握手,而这正是问题所在curl: (35) error:1400410B:SSL routines:CONNECT_CR_SRVR_HELLO:wrong version number。
我认为这没问题,因为在之前使用 SSL 的服务中,我将端口 80 和 443 路由到 puma 上的 3000。我不确定如果在 puma 上将 443 路由到 80 会发生什么,但它肯定会破坏 nginx。更改上述服务 yaml 解决了这个问题(在确保 nginx 正在侦听 443 并listen 443 ssl;在 default.conf 中启用了 SSL 之后):
- name: https
protocol: TCP
port: 443
targetPort: 443
Run Code Online (Sandbox Code Playgroud)