<aclass=""href="../debian_nspawn_container_on_arch_for_testing_apache_configurations/">Debian Nspawn Container On Arch For Testing Apache Configurations</a>
<aclass="current"href="./">Dynamic Cacheing Nginx Reverse Proxy For Pacman</a>
<ulclass="subnav">
<liclass="toctree-l2"><ahref="#dynamic-cacheing-nginx-reverse-proxy-for-pacman">Dynamic Cacheing Nginx Reverse Proxy For Pacman</a></li>
<ul>
<li><aclass="toctree-l3"href="#you-set-up-a-dynamic-cacheing-reverse-proxy-and-then-you-put-the-ip-address-or-hostname-for-that-server-in-etcpacmandmirrorlist-on-your-client-machines">You set up a dynamic cacheing reverse proxy and then you put the ip address or hostname for that server in /etc/pacman.d/mirrorlist on your client machines.</a></li>
<li><aclass="toctree-l3"href="#systemd-service-that-cleans-the-proxy-cache">systemd service that cleans the proxy cache</a></li>
<li><aclass="toctree-l3"href="#systemd-timer-for-the-systemd-service-that-cleans-the-proxy-cache">systemd timer for the systemd service that cleans the proxy cache</a></li>
<li><aclass="toctree-l3"href="#systemd-service-that-deletes-the-pacman-database-files-from-the-proxy-cache">systemd service that deletes the pacman database files from the proxy cache</a></li>
<li><aclass="toctree-l3"href="#systemd-timer-for-the-systemd-service-that-deletes-the-pacman-database-files-from-the-proxy-cache">systemd timer for the systemd service that deletes the pacman database files from the proxy cache</a></li>
</ul>
</ul>
</li>
<liclass="toctree-l1">
<aclass=""href="../arch_redis_nspawn/">Quick Dirty Redis Nspawn Container on Arch Linux</a>
</li>
<liclass="toctree-l1">
<aclass=""href="../arch_postgresql_nspawn/">Quick Dirty Postgresql Nspawn Container on Arch Linux</a>
</li>
<liclass="toctree-l1">
<aclass=""href="../self_signed_certs/">Self Signed Certs</a>
<li>Dynamic Cacheing Nginx Reverse Proxy For Pacman</li>
<liclass="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<divrole="main">
<divclass="section">
<h1id="dynamic-cacheing-nginx-reverse-proxy-for-pacman">Dynamic Cacheing Nginx Reverse Proxy For Pacman</h1>
<h2id="you-set-up-a-dynamic-cacheing-reverse-proxy-and-then-you-put-the-ip-address-or-hostname-for-that-server-in-etcpacmandmirrorlist-on-your-client-machines">You set up a dynamic cacheing reverse proxy and then you put the ip address or hostname for that server in <code>/etc/pacman.d/mirrorlist</code> on your client machines.</h2>
<p>Of course if you want to you can set this up and run it in an
<ahref="../nspawn/">Nspawn Container</a>.
The <ahref="https://wiki.archlinux.org/index.php/Pacman/Tips_and_tricks#Dynamic_reverse_proxy_cache_using_nginx">ArchWiki Page for pacman tips</a>
mostly spells out what to do, but I want to document
the exact steps I would take.</p>
<p>As for how you would run this on a server with other virtual hosts?
Who cares? That is what is so brilliant about using using an
nspawn container, in that it behaves like just another
computer on the lan with it's own ip address. But it only does one
thing, and that's all you have to configure it for.</p>
<p>I see no reason to use nginx-mainline instead of stable.</p>
<pre><codeclass="bash">pacman -S nginx
</code></pre>
<p>The suggested configuration in the Arch Wiki
is to create a directory <code>/srv/http/pacman-cache</code>,
Description=Timer for clean The pacman proxy cache
[Timer]
OnBootSec=20min
OnUnitActiveSec=100h
Unit=proxy_cache_clean.service
[Install]
WantedBy=timers.target
</code></pre>
<h2id="systemd-service-that-deletes-the-pacman-database-files-from-the-proxy-cache">systemd service that deletes the pacman database files from the proxy cache</h2>
<h3id="dont-enable-the-service-enable-the-timer_1">don't enable the service, enable the timer</h3>
ExecStart=/bin/bash -c "for f in $(find /srv -name *db) ; do rm $f; done"
StandardOutput=syslog
StandardError=syslog
</code></pre>
<h2id="systemd-timer-for-the-systemd-service-that-deletes-the-pacman-database-files-from-the-proxy-cache">systemd timer for the systemd service that deletes the pacman database files from the proxy cache</h2>
Built with <ahref="http://www.mkdocs.org">MkDocs</a> using a <ahref="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <ahref="https://readthedocs.org">Read the Docs</a>.