I would like to create an RPM repository for Fedora packages on my local network. Due to storage limitations, I want the repository to be empty initially and download packages once they are accessed.
Background
I work a lot with local VMs. Anytime I create a new VM and install Fedora, a lot of packages are downloaded from the internet, and most of the downloaded packages are the same. To speed up the process I would like the RPMs to be cached on a server located on the same network.
Similar questions have been answered with a combination of createrepo & reposync. I do not like the reposync part, because I don't want to clone the whole repository up front when I need only some of the packages.
Ideal Solution
I would like the server on my local network to act as an RPM repository for my Fedora installations. It should pass-through the metadata from whatever is configured in /etc/yum.repo.d/*. The server should deliver the requested RPM if it is present in the local cache, or else download it and then deliver it.
A less ambitious approach would be to configure a single RPM repository instead of https://mirrors.fedoraproject.org/... and just use an http proxy.
Update: 02 Nov. 2015
I already have an nginx running on the network, so I played around with a combination of proxy_pass and proxy_cache. It kinda works, but IMHO it has more drawbacks than benefits:
- a separate configuration for every repo configured in
/etc/yum.repo.d/*. - can't use
metadatafromhttps://mirrors.fedoraproject.org/because of alternate mirrors.
I dropped the nginx thing and installed squid, as suggested in comments. squid works great for me. With the store_id_program configuration, I am even able to use the alternate mirrors and still hit the cache, no matter where the RPM came from originally.