Local Mirror for FreeBSD Pkgbase

(blog.feld.me)

3 points | by birdculture 4 hours ago ago

1 comments

  • 8by3 4 hours ago ago

    I do the same thing with nginx, cache the pkgs for a month but the metadata only for 30m, as otherwise you don't know when things get updated. I cache it in ram as I have more than I need and don't need old pkgs sitting around on disk.

    ---

    proxy_cache_path /var/cache/nginx/pkg levels=1:2 keys_zone=pkg_cache:10m max_size=4g inactive=30d use_temp_path=off;

    proxy_cache_path /var/cache/nginx/pkg-meta levels=1:2 keys_zone=pkg_meta:5m max_size=500m inactive=1h use_temp_path=off;

    server { listen 80; server_name pkg.8by3.net;

        location ~\* /All/[^/]+\.pkg$ {
            proxy_pass https://pkg.freebsd.org;
            proxy_cache pkg_cache;
            proxy_cache_valid 200 30d;
            proxy_cache_use_stale error timeout updating;
            proxy_cache_lock on;
            proxy_ssl_server_name on;
            proxy_set_header Host pkg.freebsd.org;
            proxy_ignore_headers Cache-Control Expires Set-Cookie;
            add_header X-Cache-Status $upstream_cache_status always;
        }
    
        
        location / {
            proxy_pass https://pkg.freebsd.org;
            proxy_cache pkg_meta;
            proxy_cache_valid 200 30m;
            proxy_cache_valid 404 1m;
            proxy_cache_use_stale error timeout updating;
            proxy_cache_lock on;
            proxy_ssl_server_name on;
            proxy_set_header Host pkg.freebsd.org;
            proxy_ignore_headers Cache-Control Expires Set-Cookie;
            add_header X-Cache-Status $upstream_cache_status always;
        }