apiVersion: v1
kind: ConfigMap

metadata:
  name: happa-nginx-config
  namespace: giantswarm
  labels:
    app: happa

data:
  nginx.conf: |
    error_log stderr warn;
    worker_processes 1;

    events {
      worker_connections 100;
    }

    http {
      keepalive_timeout 5s;

      include /etc/nginx/mime.types;
      default_type  application/octet-stream;

      gzip on;
      gzip_proxied any;

      gzip_types text/plain text/xml text/css
                 text/comma-separated-values
                 text/javascript application/javascript
                 application/atom+xml application/json
                 image/svg+xml;

      log_format  custom  '"$request" '
          '$status $body_bytes_sent $request_time '
          '"$http_x_forwarded_for" '
          '"$http_user_agent" "$http_referer"';

      server {
        listen 8000;

        access_log /dev/stdout custom;
        client_max_body_size 0;
        chunked_transfer_encoding on;

        add_header X-Backend-Server $hostname;

        error_page 404 /404.html;

        root /www;

        location / {
          index index.html;

          try_files $uri $uri/ /index.html;

          # kill cache for any happa page (but not the javascript or other assets)
          add_header Last-Modified $date_gmt;
          add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
          if_modified_since off;
          expires off;
          etag off;
        }

        location = /404.html {
          add_header Cache-Control "no-cache" always;
        }

        location /assets {
          expires max;
        }

        location /vendor {
          expires max;
        }
      }
    }
