35 lines
1.2 KiB
Plaintext
35 lines
1.2 KiB
Plaintext
map $ssl_client_s_dn $lb_identity_allowed {
|
|
default 0;
|
|
~CN=messenger-lb$ 1;
|
|
}
|
|
server {
|
|
listen 8443 ssl;
|
|
server_name api1 api2;
|
|
ssl_certificate /run/tls/api-server.crt;
|
|
ssl_certificate_key /run/tls/api-server.key;
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
ssl_client_certificate /run/tls/service-ca.crt;
|
|
ssl_verify_client on;
|
|
ssl_verify_depth 2;
|
|
client_max_body_size 11m;
|
|
|
|
error_page 502 504 = @app_unavailable;
|
|
location / {
|
|
if ($lb_identity_allowed = 0) { return 403; }
|
|
proxy_pass http://127.0.0.1:8080;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Connection "";
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Forwarded-For $http_x_forwarded_for;
|
|
proxy_set_header X-Real-IP $http_x_real_ip;
|
|
proxy_set_header X-Forwarded-Proto https;
|
|
proxy_set_header X-Request-Id $http_x_request_id;
|
|
}
|
|
location @app_unavailable {
|
|
default_type application/json;
|
|
add_header X-Request-Id $http_x_request_id always;
|
|
add_header X-Instance-Id $server_name always;
|
|
return 503 '{"error":{"code":"unavailable","message":"API process unavailable","request_id":"$http_x_request_id"}}';
|
|
}
|
|
}
|