apiVersion: v1
kind: ConfigMap
metadata:
  name: ironic-console
  labels:
    system: openstack
    type: config
    component: ironic
data:
  default.conf: |
    map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
    }

    server {
        listen       80;
        server_name  {{ include "ironic_console_endpoint_host_public" . }};

        location ~* "/[^/]*/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/([0-9]*)/([^/]*)/?(.*)$" {
            secure_link $3,$2;
            secure_link_md5 "$secure_link_expires$1 {{required "A valid .Values.console.secret required!" .Values.console.secret}}";

            if ($secure_link = "") {
                return 403;
            }

            if ($secure_link = "0") {
                return 410;
            }

            proxy_pass http://unix:/shellinabox/$1.sock:/$4;
            proxy_set_header    Host      $host;
            proxy_http_version  1.1;
            proxy_redirect      off;
            proxy_buffering     off;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
        }

        location /health {
            access_log off;
            return 204;
        }
    }
