geo $realip_remote_addr $ingress_peer_trusted { default 0; 192.0.2.1/32 1; 2001:db8::1/128 1; } real_ip_header X-Forwarded-For; real_ip_recursive off; set_real_ip_from 192.0.2.1/32; set_real_ip_from 2001:db8::1/128; server { listen 80 default_server; server_name ""; location = /health { access_log off; default_type text/plain; return 200 "ok\n"; } location / { return 444; } } server { listen 80; server_name jobs.example.test; if ($ingress_peer_trusted = 0) { return 403; } if ($http_x_forwarded_proto != "https") { return 400; } if ($http_x_forwarded_for = "") { return 400; } if ($http_x_forwarded_for ~ ",") { return 400; } # A malformed address is not forwarded verbatim: realip leaves the socket IP intact. add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "DENY" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always; root /usr/share/nginx/html; index index.html; location / { try_files $uri /index.html; } location = /health { proxy_pass http://backend-web:8080/health; proxy_http_version 1.1; proxy_set_header Host jobs.example.test; proxy_set_header X-Real-IP $remote_addr; # realip resolves one sanitized address only from an explicitly trusted socket peer. proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Forwarded-Host ""; proxy_set_header Forwarded ""; } location = /ready { proxy_pass http://backend-web:8080/ready; proxy_http_version 1.1; proxy_set_header Host jobs.example.test; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Forwarded-Host ""; proxy_set_header Forwarded ""; } location /api/ { proxy_pass http://backend-web:8080; proxy_http_version 1.1; proxy_set_header Host jobs.example.test; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Forwarded-Host ""; proxy_set_header Forwarded ""; } }