apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx
data:
  default.conf: |
    proxy_cache_path /tmp/nginx_cache levels=1:2 keys_zone=cache:30m max_size=250m;
    proxy_temp_path /tmp/nginx_proxy 1 2;
    server {
        listen 80;
        server_name _;
        client_max_body_size 100M;
        location / {
            proxy_pass http://ckan:5000;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header Host $http_host;
            proxy_cache cache;
            proxy_cache_bypass $cookie_auth_tkt;
            proxy_no_cache $cookie_auth_tkt;
            proxy_cache_valid 30m;
            proxy_cache_key $http_host$scheme$proxy_host$request_uri;
            # In emergency comment out line to force caching
            # proxy_ignore_headers X-Accel-Expires Expires Cache-Control;
        }
    }

    {{ if .Values.pipelines.enabled }}
    server {
      listen 80;
      server_name pipelines.odata.org.il;
      location = / {
          return 200 'it works!';
          add_header Content-Type text/plain;
      }
      location /ckan/ {
        index null;
        root /var/lib/;
        autoindex on;
        auth_basic "Restricted Content";
        auth_basic_user_file /etc/htpasswd/secret-nginx-htpasswd;
      }
      location /pipelines/ {
        proxy_pass http://pipelines:5050/;
        auth_basic "Restricted Content";
        auth_basic_user_file /etc/htpasswd/secret-nginx-htpasswd;
      }
    }
    {{ end }}
