apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-files
  namespace: infra
  labels:
    name: nginx-files
    namespace: infra
data:
  nginx.conf: |
    events {
      worker_connections  1024;
    }

    http {
      sendfile    on;
      tcp_nopush  on;
      tcp_nodelay on;

      keepalive_timeout     60;
      types_hash_max_size   2048;
      client_max_body_size  100m;

      include       mime.types;
      default_type  application/octet-stream;
      access_log    /var/log/nginx/access.log;
      error_log     /var/log/nginx/error.log;

      gzip                on;
      gzip_vary           on;
      gzip_proxied        any;
      gzip_comp_level     6;
      gzip_buffers 16     8k;
      gzip_http_version   1.1;
      gzip_types          text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

      upstream k8s {
        server kubernetes-dashboard.kube-system:80;
      }

        server {
          listen    443 ssl;
          listen    [::]:443 ssl;
          root      /usr/share/nginx/html;

          ssl on;
          ssl_certificate       "/etc/nginx/cert/cert.pem";
          ssl_certificate_key   "/etc/nginx/cert/cert.pem";

          ssl_session_cache shared:SSL:1m;
          ssl_session_timeout 10m;
          ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
          ssl_ciphers HIGH:SEED:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!RSAPSK:!aDH:!aECDH:!EDH-DSS-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA:!SRP;
          ssl_prefer_server_ciphers on;

          auth_basic           "authorization required";
          auth_basic_user_file /etc/nginx/auth/htpasswd;

          server_name   ~^logs[.].*$;

          location / {
            resolver            kube-dns.kube-system valid=1s;
            set $server         kibana.infra.svc.cluster.local:5601;
            rewrite             ^/(.*) /$1 break;
            proxy_pass          http://$server;
            proxy_set_header    Host $host;
            proxy_set_header    X-Real-IP $remote_addr;
            proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header    X-Forwarded-Proto $scheme;
          }
        }

    }
