apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-conf
data:
  nginx.conf: |
    user www-data;
    worker_processes 4;
    pid /run/nginx.pid;

    events {
            worker_connections 768;
            # multi_accept on;
    }

    http {
        # General Settings
        gzip  on;
        sendfile on;
        tcp_nopush on;
        tcp_nodelay off;
        server_tokens off;
        # include mime.types;
        keepalive_timeout 5;
        default_type  application/octet-stream;

        server {
            listen 3000;
            listen 3773;
            server_name ~^(?<subdomain>.*)-(?<port>.+?)\.(?<namespace>.*)\.(?<domain>.+)\.(?<tld>.*)$;

            location /health {
              access_log off;
              return 200;
              add_header Content-Type text/plain;
            }

            location / {
              resolver        10.43.0.10;
              proxy_pass      http://$subdomain.public.svc.cluster.local:$port;
              proxy_redirect off;
              proxy_set_header        Host    $subdomain.$domain.$tld;
              proxy_set_header        X-Real-IP $remote_addr;
              proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
              
              proxy_http_version          1.1;
              proxy_set_header Upgrade    $http_upgrade;
              proxy_set_header Connection "upgrade";
            }
        }
    }
