apiVersion: v1
kind: ConfigMap
metadata:
  name: ganymede-nginx-conf
  namespace: default
data:
  nginx.conf: |
    worker_processes auto;
    worker_rlimit_nofile 65535;
    error_log  /var/log/nginx/error.log info;
    pid        /tmp/nginx.pid;

    events {
      multi_accept       on;
      worker_connections 65535;
    }

    http {
      sendfile on;
      sendfile_max_chunk 1m;
      tcp_nopush on;
      tcp_nodelay on;

      keepalive_timeout 65;
      gzip on;

      server {
        listen 8080;
        root /vods;

        add_header 'Access-Control-Allow-Origin' '*' always;
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
        add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
        add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;

        location ^~ /vods {
          autoindex on;
          alias /vods;

          location ~* \.(ico|css|js|gif|jpeg|jpg|png|svg|webp)$ {
              expires 30d;
              add_header Pragma "public";
              add_header Cache-Control "public";
          }
          location ~* \.(mp4)$ {
              add_header Content-Type "video/mp4";
              add_header 'Access-Control-Allow-Origin' '*' always;
              add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
              add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
              add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
          }
        }
      }
    }