Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Feb 2024 13:28:11 -0800
From:      Craig Leres <leres@freebsd.org>
To:        freebsd-hackers@freebsd.org
Subject:   How to use an apache proxy+cache with pkg?
Message-ID:  <df12b9a6-0eaa-4232-905c-aa4ceadd6e2c@freebsd.org>

next in thread | raw e-mail | index | archive | help
Although I have gig fiber at home, when I do pkg updates I get at most 
10 mbps from my custom build server (likely thanks to purposely bad at&t 
peering connections). I tried recently to configure apache on my home 
network to proxy and cache but haven't been able to make it work yet -- 
seems like pkg tries *really* hard to defeat caching.

First I was hitting the CacheMaxFileSize default of 1000000 (which I 
would describe as ridiculously low).

Then I figured out that pkg was appending '?' to make the downloads look 
like queries so I turned CacheIgnoreQueryString on.

Next I saw that pkg was setting an If-Modified-Since to Jan 1970, 
CacheIgnoreCacheControl solved that.

But it still doesn't cache and it feels like I'm missing some obvious 
knob (maybe in pkg.conf?) My config works for fetch and curl but not pkg.

I think I saw some ngix configs to do this but I'm already using apache 
for other stuff and would prefer to not have to install ngix... Is 
anybody doing this with apache?

For extra credit, I'd like to do the same for freebsd-update blobs.

		Craig

ProxyRequests Off
ProxyPreserveHost Off

ProxyPass / http://pkg.example.com/
ProxyPassReverse / http://pkg.example.com/
ProxyHTMLURLMap http://pkg.example.com/ http://pkg.local.example.com/

CacheEnable disk /
CacheRoot /var/cache/freebsd-pkg
#CacheIgnoreNoLastMod On
CacheDetailHeader On
#CacheIgnoreHeaders Set-Cookie
# Default is ridiculously small (1000000 or 0.95MB)
CacheMaxFileSize 200000000
CacheMinFileSize 1024
CacheIgnoreQueryString On
CacheIgnoreCacheControl On

#LogLevel proxy:debug
#LogLevel cache:debug
#LogLevel cache_disk:debug




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?df12b9a6-0eaa-4232-905c-aa4ceadd6e2c>