apiVersion: v1
kind: ConfigMap
metadata:
  name: tradingdb-configmap
data:
  tradingdb.conf: |
    # NGINX conf for tradingdb

    # https://github.com/KyleAMathews/docker-nginx/blob/master/nginx.conf
    # https://linode.com/docs/web-servers/nginx/configure-nginx-for-optimized-performance/

    #events {
    #  worker_connections 8000;  # increase if you have lots of clients
    #  accept_mutex on;  # set to 'on' if nginx worker_processes > 1
    #  use epoll;  # to enable for Linux 2.6+
    #}

    upstream web {
      ip_hash;
      # server web:8000;
      server unix:/nginx/gunicorn.socket fail_timeout=0;
    }

    server {
      listen 8000;
      charset utf-8;

      keepalive_timeout 65;
      keepalive_requests 100000;
      sendfile on;
      tcp_nopush on;
      tcp_nodelay on;


      gzip             on;
      gzip_min_length 256;
      gzip_comp_level  5;

      # text/html is always included by default
      gzip_types text/plain text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/rss+xml application/atom+xml application/rdf+xml;
      gzip_disable "MSIE [1-6]\.";

      location / {
            proxy_pass http://web/;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-Host $server_name;
            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;
            add_header              Front-End-Https   on;
            # we don't want nginx trying to do something clever with
            # redirects, we set the Host: header above already.
            proxy_redirect off;
      }

      location /static {
            alias /nginx/staticfiles;
      }
    }
