# Dedicated customer TCP entry point for /relay-replacement. # Requires the stream and stream_ssl_preread modules; use separate Portal # processes on :8443 (old) and :9443 (new). Reserve loopback :10443 for rejection. # Install as /etc/nginx/portal-entry.conf and use the same -c/-p on every command. # Debian/Ubuntu dynamic module loaders; install the matching stream package. # For statically built nginx, omit this include. Other distributions must use # their matching absolute load_module path before the stream block instead. include /etc/nginx/modules-enabled/*.conf; pid /run/nginx-portal-entry.pid; error_log /var/log/nginx/portal-entry-error.log notice; worker_processes auto; worker_shutdown_timeout 10m; events { worker_connections 4096; } stream { # Exact DNS names can be up to 253 bytes, plus hash-entry overhead. map_hash_bucket_size 512; log_format relay '$pid $remote_addr $upstream_addr $status $session_time'; access_log /var/log/nginx/portal-entry-sessions.log relay; upstream customer_relay { # After every tunnel is ready, change to :9443 and gracefully reload. server 127.0.0.1:8443; } map $ssl_preread_server_name $customer_backend { # Reject root/API SNI, empty SNI, and every unlisted hostname. default 127.0.0.1:10443; # Replace with the exact customer hostnames approved for this entry. # Do not include portal.example.com or use a catch-all relay upstream. app-0123456789abcdef0123456789abcdef01234567.portal.example.com customer_relay; } server { listen 443; # Add an IPv6 listener when the public hostname also has an AAAA record. # listen [::]:443; ssl_preread on; proxy_pass $customer_backend; proxy_connect_timeout 5s; proxy_timeout 24h; # Inactivity timeout, not the drain deadline. proxy_half_close on; # No TLS termination and no PROXY protocol header toward Portal. } server { listen 127.0.0.1:10443; return ""; # Close rejected connections without forwarding to Portal. } }