community.riocities.com
  • Home
  • Categories
  • Tags
  • Archives

Fronting apt-cacher-ng with nginx

Why: I have some isolated islands in the network that are using a local apt-cacher-ng instance. To optimize the caching I am moving to one central cache and instead let the isolated islands connect via a proxy provided by nginx.

sudo apt-get install nginx-light

Disable the default site

sudo rm /etc/nginx/sites-enabled/default

Configure the proxy as a new site in /etc/nginx/sites-available/apt-cacher-ng

upstream apt-cacher-ng {
  server aptproxy.example.com:9999;
  server 127.0.0.1:9998 backup;
}

server {
  listen   9999;

  location / {
    proxy_pass http://apt-cacher-ng;
    proxy_redirect off;
    proxy_buffering off;
    proxy_set_header    Host            $host;
    proxy_set_header    X-Real-IP       $remote_addr;
    proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
  }

}

The local apt-cacher-ng instance is running as a backup on port 9998 and used in case the central is down.

enable the new "site"

cd /etc/nginx/sites-enabled/
sudo ln -s /etc/nginx/sites-available/apt-cacher-ng .

start nginx

sudo service nginx start

Note: If you would like the X-Forwarded-For info to be seen in the apt-cacher-ng log you must enable LogSubmittedOrigin option in apt-cacher-ng/acng.conf.


  • « HP ProLiant MicroServer Gen8
  • Debian based XEN Network Driver Domain »

Published

Feb 10, 2015

Author

henrik

Category

HOWTOs

Tags

  • apt-cacher-ng 2

Social

  • atom feed
  • rss feed
  • ipv6 ready
  • Powered by Pelican. Theme: Elegant by Talha Mansoor