include ./vhosts/cdnproxy;

server {
        listen       80;
        server_name  localhost;
        #charset koi8-r;
        location / {
                proxy_pass http://cdncache/;
                proxy_set_header Host  $host:$http_port;
                proxy_set_header X-Forwarded-For  $remote_addr;
                proxy_cache mpcache;
                proxy_cache_key $host$uri$is_args$args;
                proxy_set_header Range $slice_range;
                proxy_cache_valid 200 206 90d;
                proxy_cache_valid 304 1h;
                proxy_cache_valid 404 403 1m;
                proxy_cache_valid 502 504 1m;
                proxy_cache_lock on;
                proxy_cache_lock_timeout 5s;
                proxy_redirect off;
                add_header  CDN-Cache "$upstream_cache_status";
                allow             127.0.0.1;
                deny               all;
        }

        location ~ /purge(/.*) {
                allow              127.0.0.1;
                deny               all;
                proxy_cache_purge  mpcache $host$1$is_args$args;
        }

        location ~ /audio(/.*) {
                autoindex on;
                autoindex_exact_size on;
                autoindex_localtime on;
                root  /app/sd01/webserver/;
                charset gbk,utf8;
                proxy_set_header        Host $host:$http_port;
                proxy_set_header        X-Real-IP $remote_addr;
                proxy_set_header        User-Agent $http_user_agent;
                proxy_set_header        Referer $http_referer;
                proxy_set_header        X-Forward-For $proxy_add_x_forwarded_for;
                allow              127.0.0.1;
                deny               all;
        }
}

