{"id":5098,"date":"2026-01-17T18:34:49","date_gmt":"2026-01-17T23:34:49","guid":{"rendered":"https:\/\/dft.wiki\/?p=5098"},"modified":"2026-01-19T13:40:28","modified_gmt":"2026-01-19T18:40:28","slug":"local-repositories-and-mirrors","status":"publish","type":"post","link":"https:\/\/dft.wiki\/?p=5098","title":{"rendered":"Local Repositories and Mirrors"},"content":{"rendered":"<p>Having packages served locally can increase server performance during installations and updates, and reduce internet bandwidth utilization on repeated fetches.<\/p>\n<ul>\n<li><strong>Option 1<\/strong> &#8211; Install a Proxy Cache for APT packages in the LAN [<a href=\"https:\/\/salsa.debian.org\/blade\/apt-cacher-ng\/-\/tree\/upstream\/experimental\">Link<\/a>].\n<ul>\n<li>This alternative is dynamic since it does not require setting up each repository for each distribution + version.<\/li>\n<li>As the first host in the network fetches a package, it gets cached to serve the next time the same or another host requires 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> Make sure the volume where the cache directory (<code>\/var\/cache\/apt-cacher-ng<\/code>) is located and has enough space, set parameters accordingly (<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 a 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>Watch the hits and misses of the cache and set a few 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 great option for data centers because the huge volume of requests justifies storing so much data.<\/li>\n<li>Each repository can easily be 100GB big and requires setting up and periodic synchronization.<\/li>\n<li>It can be accomplished with <code>apt-mirror<\/code>, <code>debmirror<\/code>, <code>reprepro<\/code>\u00a0, 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 use your local server.<\/p>\n<pre>sudo nano \/etc\/apt\/sources.list<\/pre>\n<p>In the example below, it assumes that it has resolved locally the mock domain <strong>ubuntumirror.lan<\/strong> to the IP of the server that contains 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>\u00a0to 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>Having packages served locally can increase server performance during installations and updates, and reduce internet [&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":4,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/5098\/revisions"}],"predecessor-version":[{"id":5252,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/5098\/revisions\/5252"}],"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}]}}