apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-config-configmap
data:
  nginx.conf: |-
    user  nginx;
    worker_processes  1;

    error_log  /var/log/nginx/error.log warn;
    pid        /var/run/nginx.pid;

    events {
        worker_connections  1024;
    }

    http {
        include       /etc/nginx/mime.types;
        default_type  application/octet-stream;
        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" "$http_x_forwarded_for"';
        access_log  /var/log/nginx/access.log  main;
        sendfile        on;
        #tcp_nopush     on;
        keepalive_timeout  65;

        #gzip  on;

        upstream django {
        server {{ .Release.Name }}-studio:8080;
        }

        map $http_upgrade $connection_upgrade {
            default upgrade;
            '' close;
        }

        server {

                listen 80 default_server;
                listen [::]:80 default_server;

                server_name _;
                #{{ .Values.domain }};

                root /var/www/;

                #location = /favicon.ico { access_log off; log_not_found off; }
                #location /static/ {
                #      root /var/www/static/;
                #      gzip on;
                #      gzip_types application/javascript image/* text/css;
                #      gunzip on;
                #      try_files $uri $uri/ =404 ;
                #      sendfile on;
                #      tcp_nopush on;
                #      tcp_nodelay on;
                #      keepalive_timeout 65;
                #}

                location / {
                    proxy_pass http://django;
                    proxy_set_header Host $http_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;
                    client_max_body_size 0;
                }
        }
    }
