forked from mtusi2026/mtusi2026lab7
57 lines
1.7 KiB
Nginx Configuration File
57 lines
1.7 KiB
Nginx Configuration File
events {
|
|
worker_connections 1024;
|
|
}
|
|
|
|
http {
|
|
resolver 127.0.0.11 valid=2s ipv6=off;
|
|
resolver_timeout 2s;
|
|
|
|
upstream messenger_api {
|
|
zone messenger_api 64k;
|
|
|
|
server api1:8443 resolve max_fails=1 fail_timeout=2s;
|
|
server api2:8443 resolve max_fails=1 fail_timeout=2s;
|
|
}
|
|
|
|
server {
|
|
listen 443 ssl;
|
|
server_name localhost;
|
|
|
|
ssl_certificate /run/lab7-pki/ingress.crt;
|
|
ssl_certificate_key /run/lab7-pki/ingress.key;
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
|
|
client_max_body_size 11m;
|
|
|
|
location / {
|
|
proxy_pass https://messenger_api;
|
|
proxy_http_version 1.1;
|
|
|
|
# Verify the server certificate on every API connection.
|
|
proxy_ssl_trusted_certificate /run/lab7-pki/ca.crt;
|
|
proxy_ssl_verify on;
|
|
proxy_ssl_verify_depth 2;
|
|
|
|
# Each upstream has its own DNS identity.
|
|
proxy_ssl_name messenger-api.internal;
|
|
proxy_ssl_server_name on;
|
|
|
|
# Nginx authenticates as the authorized LB.
|
|
proxy_ssl_certificate /run/lab7-pki/lb-client.crt;
|
|
proxy_ssl_certificate_key /run/lab7-pki/lb-client.key;
|
|
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto https;
|
|
|
|
proxy_connect_timeout 2s;
|
|
proxy_read_timeout 30s;
|
|
proxy_send_timeout 30s;
|
|
|
|
proxy_next_upstream error timeout http_502 http_503 http_504;
|
|
proxy_next_upstream_tries 2;
|
|
}
|
|
}
|
|
}
|