{"id":5098,"date":"2026-01-17T18:34:49","date_gmt":"2026-01-17T23:34:49","guid":{"rendered":"https:\/\/dft.wiki\/?p=5098"},"modified":"2026-06-08T09:20:38","modified_gmt":"2026-06-08T13:20:38","slug":"local-repositories-and-mirrors","status":"publish","type":"post","link":"https:\/\/dft.wiki\/?p=5098","title":{"rendered":"Local Repositories and Mirrors"},"content":{"rendered":"<p>Serving packages locally can improve server performance during installations and updates, and reduce internet bandwidth usage on repeated downloads.<\/p>\n<ul>\n<li><strong>Option 1<\/strong> &#8211; Install a Proxy Cache for APT packages on the LAN [<a href=\"https:\/\/salsa.debian.org\/blade\/apt-cacher-ng\/-\/tree\/upstream\/experimental\">Link<\/a>].\n<ul>\n<li>This option is flexible \u2014 it does not require configuring each repository for each distribution and version separately.<\/li>\n<li>When the first host on the network fetches a package, it is cached and served to any subsequent host that requests it.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<pre>apt install apt-cacher-ng -y\r\nufw allow 3142<\/pre>\n<p><strong>Note:<\/strong> Ensure the volume hosting the cache directory (<code>\/var\/cache\/apt-cacher-ng<\/code>) has sufficient space. Adjust the relevant parameters in <code>\/etc\/apt-cacher-ng\/acng.conf<\/code> to prevent overflow.<\/p>\n<p>On the other hosts in the same network, configure <code>apt<\/code> to use the proxy.<\/p>\n<pre>echo 'Acquire::http { Proxy \"http:\/\/<strong>10.1.1.2<\/strong>:3142\"; };' | sudo tee \/etc\/apt\/apt.conf.d\/01proxy\r\necho 'Acquire::https::Proxy \"false\";' | sudo tee -a \/etc\/apt\/apt.conf.d\/01proxy\r\nsudo sed -i 's|https:\/\/|http:\/\/|g' \/etc\/apt\/sources.list\r\nsudo sed -i 's|https:\/\/|http:\/\/|g' \/etc\/apt\/sources.list.d\/*<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4961\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2025\/06\/Screenshot_2025-06-19_21-39-36.png\" alt=\"\" width=\"452\" height=\"96\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2025\/06\/Screenshot_2025-06-19_21-39-36.png 452w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2025\/06\/Screenshot_2025-06-19_21-39-36-300x64.png 300w\" sizes=\"auto, (max-width: 452px) 100vw, 452px\" \/><\/p>\n<p>Monitor cache hits and misses, and adjust parameters at <strong>http:\/\/<span style=\"text-decoration: underline;\">10.1.1.2<\/span>:3142\/acng-report.html<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4960\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2025\/06\/Screenshot_2025-06-19_21-39-07.png\" alt=\"\" width=\"780\" height=\"523\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2025\/06\/Screenshot_2025-06-19_21-39-07.png 780w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2025\/06\/Screenshot_2025-06-19_21-39-07-300x201.png 300w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2025\/06\/Screenshot_2025-06-19_21-39-07-768x515.png 768w\" sizes=\"auto, (max-width: 780px) 100vw, 780px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4964\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2025\/06\/Screenshot_2025-06-20_20-04-46.png\" alt=\"\" width=\"546\" height=\"125\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2025\/06\/Screenshot_2025-06-20_20-04-46.png 546w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2025\/06\/Screenshot_2025-06-20_20-04-46-300x69.png 300w\" sizes=\"auto, (max-width: 546px) 100vw, 546px\" \/><\/p>\n<ul>\n<li><strong>Option 2<\/strong> &#8211; Mirror the public repository.\n<ul>\n<li>This is a good fit for data centers, where the high volume of requests justifies the storage requirements.<\/li>\n<li>Each repository can exceed 100 GB and requires initial setup and periodic synchronization.<\/li>\n<li>This can be done with <code>apt-mirror<\/code>, <code>debmirror<\/code>, <code>reprepro<\/code>, or simply with <code>rsync<\/code> and a web server such as <code>apache<\/code> or <code>nginx<\/code>.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<pre>sudo apt install nginx rsync -y\r\nmkdir -p \/var\/www\/html\/ubuntu\r\nrsync -a --bwlimit=128 rsync:\/\/archive.ubuntu.com\/ubuntu \/var\/www\/html\/ubuntu<\/pre>\n<p>Update the client hosts to point to your local server.<\/p>\n<pre>sudo nano \/etc\/apt\/sources.list<\/pre>\n<p>The example below assumes that the mock domain <strong>ubuntumirror.lan<\/strong> resolves locally to the IP of the server hosting the mirror.<\/p>\n<pre>deb http:\/\/<strong>ubuntumirror.lan<\/strong>\/ubuntu\/ noble main\r\ndeb-src http:\/\/<strong>ubuntumirror.lan<\/strong>\/ubuntu\/ noble main<\/pre>\n<p><strong>SNAP Package Manager<\/strong><\/p>\n<p>Configure a proxy for <code>snap<\/code>.<\/p>\n<pre>sudo apt install snapd -y\r\nsnap install snap-store-proxy<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5024\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2025\/06\/Screenshot_2025-06-26_00-10-23.png\" alt=\"\" width=\"362\" height=\"70\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2025\/06\/Screenshot_2025-06-26_00-10-23.png 362w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2025\/06\/Screenshot_2025-06-26_00-10-23-300x58.png 300w\" sizes=\"auto, (max-width: 362px) 100vw, 362px\" \/><\/p>\n<p>On the client side, configure <code>snap<\/code> to use the proxy.<\/p>\n<pre>sudo snap set system proxy.http=\"http:\/\/10.1.1.2:<strong>3128<\/strong>\"\r\nsudo snap set system proxy.https=\"http:\/\/10.1.1.2:<strong>3128<\/strong>\"\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Serving packages locally can improve server performance during installations and updates, and reduce internet bandwidth [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,1],"tags":[],"class_list":["post-5098","post","type-post","status-publish","format-standard","hentry","category-linux","category-ccna"],"_links":{"self":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/5098","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5098"}],"version-history":[{"count":5,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/5098\/revisions"}],"predecessor-version":[{"id":5596,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/5098\/revisions\/5596"}],"wp:attachment":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5098"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5098"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5098"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}