{{- $namespace := .Release.Namespace -}}
---
kind: ConfigMap
apiVersion: v1
metadata:
  name: nginx-cm
  namespace: {{ $namespace }}
  labels:
    cmii.type: {{ $.Values.application.type }}
data:
  nginx.conf: |
    user root;
    worker_processes  1;

    events {
        worker_connections  1024;
    }
    http {
        include       mime.types;
        default_type  application/octet-stream;

        sendfile        on;

        keepalive_timeout  65;

        server {
            listen       9528;
            server_name  localhost;
            gzip on;

            location / {
                root   /home/cmii-platform/dist;
                index  index.html index.htm;
            }

            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
        }
    }
---
kind: ConfigMap
apiVersion: v1
metadata:
  name: default-nginx-cm
  namespace: {{ $namespace }}
data:
  default.conf: |
    server {
        listen       9528;
        server_name  localhost;

        location / {
            if ($request_filename ~* ^.*?\.(css|js|gif|gz|svg|mp4|ogg|ogv|webm|htc|xml|woff)$){
                # add_header    Cache-Control  no-cache;
                add_header    Cache-Control  max-age=315360000;
                # expires      30d;
            }
            root   /home/cmii-platform/dist;
            index  index.html index.htm;
            try_files $uri $uri/ /index.html;
            gzip on;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }
    }
---
