user nginx;
worker_processes auto;

error_log  /var/log/nginx/error.log notice;
pid        /var/run/nginx.pid;


events {
    worker_connections 1024;
}


http {
    resolver 127.0.0.11;
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for"';

    access_log off;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout 65;

    #gzip on;

    server {
        root /storage;
        client_max_body_size 100m;

        location @kemono {
            proxy_pass http://web:3450;
        }

        location @api {
            proxy_pass http://api:3449;
        }

        location ~ "^/archive_files/([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{60})\.(.*)" {
            proxy_pass http://foobar:5000/extract/data/$1/$2/$1$2$3.$4$is_args$args;
        }

        location /api {
            try_files /dev/null @api;
        }

        location / {
            try_files $uri @kemono;
            if ($arg_f) {
                add_header Content-Disposition "inline; filename=$arg_f";
            }
        }
    }
}
