Skip to content

Instantly share code, notes, and snippets.

@karolyi
Last active February 6, 2019 01:36
Show Gist options
  • Save karolyi/0f32b1a5a9b076b05106a1c7b7f136b0 to your computer and use it in GitHub Desktop.
Save karolyi/0f32b1a5a9b076b05106a1c7b7f136b0 to your computer and use it in GitHub Desktop.
pkgmirror.conf
proxy_cache_path /var/cache/pkgmirror/ max_size=10G inactive=1y manager_sleep=10m keys_zone=pkgirror_meta_zone:10m;
server {
listen *:80;
listen [::]:80;
server_name pkgmirror._yourdomain_;
autoindex on;
access_log /var/log/nginx/pkgmirror._yourdomain_-access.log combined2 buffer=32k flush=5m;
error_log /var/log/nginx/pkgmirror_yourdomain_-error.log info;
location / {
proxy_cache pkgirror_meta_zone;
proxy_cache_valid 200 1d;
proxy_redirect off;
proxy_cache_revalidate on;
proxy_cache_min_uses 1;
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
proxy_next_upstream error timeout http_404 http_403;
proxy_ignore_headers Expires Cache-Control;
proxy_pass http://pkg-mirrors$request_uri;
add_header X-Cache-Status $upstream_cache_status;
}
}
# Upstream FreeBSD Mirrors
upstream pkg-mirrors {
server localhost:8007;
server localhost:8008 backup;
server localhost:8009 backup;
}
# FreeBSD Global Mirror Proxy Configuration
server {
listen *:8007;
listen [::]:8007;
server_name localhost;
location / {
proxy_pass http://pkg.FreeBSD.org$request_uri;
proxy_set_header Host pkg.FreeBSD.org;
}
}
# pkgmir.geo Proxy Configuration
server {
listen *:8008;
listen [::]:8008;
server_name localhost;
location / {
proxy_pass http://pkgmir.geo.FreeBSD.org$request_uri;
proxy_set_header Host pkgmir.geo.FreeBSD.org;
}
}
# Add working mirrors if none of these works
# pkg0.nyi.freebsd.org Proxy Configuration
server {
listen *:8009;
listen [::]:8009;
server_name localhost;
location / {
proxy_pass http://pkg0.nyi.freebsd.org$request_uri;
proxy_set_header Host pkg0.nyi.freebsd.org;
}
}
# vim: set sw=4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment