proxy_cache_path  /tmp/mirrors_cache/short-cache levels=1:2 keys_zone=short-cache:10m max_size=10g inactive=168h;
proxy_cache_path  /tmp/mirrors_cache/long-cache levels=1:2 keys_zone=long-cache:10m max_size=10g inactive=1680h;
server {
    listen       80;
    listen  [::]:80;
    server_name  mirrors.litebmc.com;
    error_log /var/log/error.log warn;

    proxy_cache long-cache;
    proxy_cache_valid 168h;
    proxy_temp_path /tmp/mirrors_temp;
    add_header cache $upstream_cache_status;
    fastcgi_buffers         16  16k;
    fastcgi_buffer_size         32k;
    proxy_buffer_size          128k;
    proxy_buffers            4 256k;
    proxy_busy_buffers_size    256k;
    resolver 114.114.114.114;

    proxy_ssl_server_name on;
    proxy_intercept_errors on;
    error_page 301 302 307 = @handle_redirect;

    location /http/downloads/sourceforge/net/ {
            proxy_pass http://downloads.sourceforge.net/;
    }
    location /https/downloads/sourceforge/net/ {
            proxy_pass http://downloads.sourceforge.net/;
    }
    location @handle_redirect {
        set $saved_redirect_location '$upstream_http_location';
        proxy_cache_key "$host$request_uri $cookie_user";
        add_header X-debug-message "A sssstatic file was served $saved_redirect_location" always;
        proxy_pass $saved_redirect_location;
    }
    location /https/www/kernel/org/ {
        proxy_pass https://mirrors.edge.kernel.org/;
    }
    location /https/curl/se/ {
        proxy_ignore_headers "Cache-Control";
        proxy_pass https://curl.se/;
    }
    location /http/libestr/adiscon/com/ {
        proxy_pass https://libestr.adiscon.com/;
    }
    location /http/rsyslog/com/ {
        proxy_cache off;
        proxy_pass https://rsyslog.com/;
    }
    location /https/snapshot/debian/org/ {
        proxy_pass https://snapshot.debian.org/;
    }
    location /https/www/openssl/org/ {
        proxy_pass https://www.openssl.org/;
    }
    location /https/python/org/ftp/python/ {
        proxy_pass https://repo.huaweicloud.com/python/;
    }
    location /https/www/busybox/net/ {
        proxy_pass https://www.busybox.net/;
    }
    location /http/ftp/openbsd/org/ {
        proxy_pass http://ftp.openbsd.org/;
    }
    location /https/sources/buildroot/net/ {
        proxy_pass https://sources.buildroot.net/;
    }
    location /https/distfiles/ariadne/space/ {
        proxy_pass https://distfiles.ariadne.space/;
    }
    location /https/www/zlib/net/ {
        proxy_pass https://sources.buildroot.net/libzlib/;
    }
    location /https/git/kernel/org/ {
        proxy_pass https://git.kernel.org/;
    }
    location /https/github/com/ {
        proxy_pass https://github.com/;
    }
    location /https/launchpad/net/ {
        proxy_pass https://launchpad.net/;
    }
    location /http/downloads/xiph/org/ {
        proxy_pass http://ftp.osuosl.org/pub/xiph/;
    }
    location /https/downloads/xiph/org/ {
        proxy_pass https://ftp.osuosl.org/pub/xiph/;
    }
    location /https/files/pythonhosted/org/ {
        proxy_pass https://files.pythonhosted.org/;
    }
    location /https/gitlab-ext/sigma-chemnitz/de/ {
        proxy_pass https://gitlab-ext.sigma-chemnitz.de/;
    }
    location /https/gitlab/com/ {
        proxy_pass https://gitlab.com/;
    }
    location /https/freedesktop/org {
        proxy_pass https://freedesktop.org/;
    }
    location /https/poppler/freedesktop/org {
        proxy_pass https://poppler.freedesktop.org/;
    }
    location /https/mesa/freedesktop/org {
        proxy_pass https://mesa.freedesktop.org/;
    }
    location /https/libopenraw/freedesktop/org {
        proxy_pass https://libopenraw.freedesktop.org/;
    }
    location /https/libnice/freedesktop/org {
        proxy_pass https://libnice.freedesktop.org/;
    }
    location /https/libbsd/freedesktop/org {
        proxy_pass https://libbsd.freedesktop.org/;
    }
    location /https/www/freedesktop/org {
        proxy_pass https://www.freedesktop.org/;
    }
    location /https/dbus/freedesktop/org {
        proxy_pass https://dbus.freedesktop.org/;
    }
    location /https/icon-theme/freedesktop/org {
        proxy_pass https://icon-theme.freedesktop.org/;
    }
    location /https/anongit/freedesktop/org {
        proxy_pass https://anongit.freedesktop.org/;
    }
    location /https/gstreamer/freedesktop/org {
        proxy_pass https://gstreamer.freedesktop.org/;
    }
    location /https/dri/freedesktop/org {
        proxy_pass https://dri.freedesktop.org/;
    }
    location /https/gitlab/freedesktop/org {
        proxy_pass https://gitlab.freedesktop.org/;
    }
    location /https/xorg/freedesktop/org {
        proxy_pass https://www.x.org/;
    }
    location /https/www/x/org {
        proxy_pass https://www.x.org/;
    }
    location /https/download/gnome/org/ {
        proxy_pass https://mirrors.nju.edu.cn/gnome/;
    }
    location /http/luarocks/cn/ {
        proxy_pass http://luarocks.cn/;
    }
    location /http/sources/buildroot/net/ {
        proxy_pass http://sources.buildroot.net/;
    }
    location /CPAN/ {
        proxy_pass http://mirrors.aliyun.com/CPAN/;
    }
    location /gnu/ {
        proxy_pass http://mirrors.aliyun.com/gnu/;
    }
    location /kernel/linux/kernel {
        proxy_pass http://mirrors.tuna.tsinghua.edu.cn/kernel/;
    }
    location /ubuntu/ {
        proxy_pass http://repo.huaweicloud.com/ubuntu/;
        proxy_cache short-cache;
    }
    location /pypi/ {
        proxy_pass http://mirrors.huaweicloud.com/repository/pypi/;
        proxy_cache short-cache;
        proxy_cache_use_stale http_403;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}
