31 lines
753 B
Plaintext
31 lines
753 B
Plaintext
map $ssl_client_s_dn $lb_identity_ok {
|
|
default 0;
|
|
"~*CN=lb(,|/|$)" 1;
|
|
}
|
|
|
|
server {
|
|
listen 8443 ssl;
|
|
server_name api-gateway;
|
|
ssl_certificate /pki/gateway.crt;
|
|
ssl_certificate_key /pki/gateway.key;
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
ssl_client_certificate /pki/ca.crt;
|
|
ssl_verify_client on;
|
|
ssl_verify_depth 2;
|
|
|
|
# A trusted CA is not enough: only the LB identity may call the API.
|
|
if ($lb_identity_ok = 0) {
|
|
return 403;
|
|
}
|
|
|
|
location / {
|
|
proxy_pass http://${API_UPSTREAM}:8080;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Client-Identity $ssl_client_s_dn;
|
|
proxy_connect_timeout 2s;
|
|
proxy_read_timeout 30s;
|
|
}
|
|
}
|