worker_processes  1;
events {
    worker_connections  1024;
}
http {
  server {
      # Acts as a simple forward http proxy for the OIDC realm configuration
      listen 8888;
      location / {
          # oidc-provider is another container so we need to rewrite `127.0.0.1:ephemeralPort` with `oidc-provider:8080`
          # so that nginx can access that
          resolver 127.0.0.11;
          set $ophost "oidc-provider:8080";
          proxy_pass http://$ophost;
      }
  }

  server {
    set $ophost "oidc-provider:8443";

    listen 8889;

    # dns resolver used by forward proxying
    resolver                       127.0.0.11;

    # forward proxy for CONNECT request
    proxy_connect;
    proxy_connect_allow            1-65535;
    proxy_connect_connect_timeout  10s;
    proxy_connect_data_timeout     10s;
    proxy_connect_address          $ophost;

    location / {
        resolver 127.0.0.11;
        proxy_pass https://$ophost;
    }
  }
}

