我的 Web 服务器后端强制执行客户端证书。在我将部署转移到 Kubernetes 集群之前,这非常有效。我的猜测是转发规则没有将证书请求从服务器传递到浏览器。
我正在使用uwsgi-nginx-flask-docker 容器。
我的 Nginx 配置如下:
server {
listen 8000 ssl;
location / {
try_files $uri @app;
}
location @app {
include uwsgi_params; uwsgi_param SSL_CLIENT_S_DN $ssl_client_s_dn;
uwsgi_pass unix:///tmp/uwsgi.sock;
uwsgi_read_timeout 300;
ssl_certificate /app/cert.pem;
ssl_certificate_key /app/key.pem;
ssl_password_file /app/password.pass;
ssl_client_certificate /app/client-ca.crt;
ssl_verify_client off;
ssl_verify_depth 2;
}
location /static {
alias /app/static;
}
}
SSL_CLIENT_S_DN
在本地容器上部署此服务器时,我flask.request.environ
按预期进入。
在我的 Kubernetes 集群上,变量只是空的,浏览器上没有弹出证书需求。
我的服务和部署:
apiVersion: v1
kind: Service
metadata:
name: my-server
spec:
selector:
app: my-server
type: LoadBalancer
loadBalancerIP: XX.XX.XXX.XXX
ports:
- protocol: TCP
port: 8000
targetPort: 8000
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-server
labels:
app: my-server
spec:
replicas: 1
strategy:
type: RollingUpdate
selector:
matchLabels:
app: my-server
template:
metadata:
labels:
app: my-server
spec:
restartPolicy: Always
hostname: my-server
containers:
- name: my-server
image: asia.gcr.io/my-project/my-server:latest
imagePullPolicy: Always
ports:
- name: LISTEN_PORT
value: "8000 ssl"