server {

    listen 8000;
    
    location /cache/videos/ {
        auth_request /api/ping/;
        alias /cache/videos/;
    }
    
    location /cache/channels/ {
        auth_request /api/ping/;
        alias /cache/channels/;
    }
    
    location /cache/playlists/ {
        auth_request /api/ping/;
        alias /cache/playlists/;
    }
    
    location /media/ {
        auth_request /api/ping/;
        alias /youtube/;
        types {
            text/vtt vtt;
        }
    }

    location /youtube/ {
        auth_request /api/ping/;
        alias /youtube/;
        types {
            video/mp4 mp4;
        }
    }
    
    location /api {
        include proxy_params;
        proxy_pass http://localhost:8080;
    }

    location /admin {
        include proxy_params;
        proxy_pass http://localhost:8080;
    }

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

    root   /app/static;
    index  index.html;

    location ~* .(?:css|js)$ {    
        try_files $uri $uri/ /index.html =404;
    }

    location = /index.html {
        add_header Cache-Control 'no-store';
        expires 0;
    }

    location / {
        add_header Cache-Control 'no-store';
        try_files $uri $uri/ /index.html =404;
    }
}
