Giter Site home page Giter Site logo

angry-caching-proxy's Introduction

Build Status

Angry Caching Proxy

screenshot

Make package downloads lightning fast for apt-get, npm, pip and Rubygems!

Angry Caching Proxy is forwarding proxy for various package managers. It is configured transparently to the clients using the http_proxy environment variable. So there is no need to have customized sources.list, Gemfile etc.

It works by doing very angry caching (forever!) for the actual package files. This should be ok as long as the package authors won't override already uploaded packages. It is a very bad practice by the package authors and happens very rarely. If it happens anyway you can always clear the cache from the web interface of Angry Caching Proxy.

Use cases

Installing or upgrading multiple Ubuntu machines. In the worst case you have to download gigabytes of .deb packages for each machine. With Angry Caching Proxy the packages are downloaded once and then served instantly from the cache.

When doing distributed builds it might be hard to share local disk caches.

Just speeding up your local bundle install runs.

Install

Get node.js and type

sudo npm install -g angry-caching-proxy

or if you don't like sudoing random code you can install it locally too:

npm install angry-caching-proxy

and execute it with

node_modules/.bin/angry-caching-proxy

Configuration

Create /etc/angry-caching-proxy/config.json with any of the following keys:

  • directory: Where to store cached requests.
  • port: Port to listen.
    • default: 8080
  • workers: Workers to use. Default to machine cpu core count.
  • customTriggers: Path to custom triggers module.
    • default: /etc/angry-caching-proxy/triggers.js
  • triggers: Array of triggers to activate.
    • default ["apt-get", "npm", "pypi", "rubygems"]

Custom triggers

If you want to add additional caching you can create /etc/angry-caching-proxy/triggers.js file with your own caching functions. It should export an object of functions that return true when the request should be cached. The caching occurs only if the upstream responds with http success status 200. Only GET requests can be cached.

Example:

module.exports = {
    "custom": function isMyCustomCacheRequest(req, res) {
        // Cache all requests that contain X-My-Cache header
        return req.headers["X-My-Cache"]);
    },
};

See buildin-triggers.js for examples.

New build-in triggers are also welcome as a pull request.

Usage

Create directory where to save cached requests

mkdir cache

and start the server

angry-caching-proxy --directory cache

You can inspect and clear the cache by browsing directly to the proxy address http://localhost:8080

apt-get

http_proxy=http://localhost:8080 sudo -E apt-get install sl

Bundler (Rubygems)

http_proxy=http://localhost:8080 bundle install

npm

With npm it is required to use the non-https version of the registry

http_proxy=http://localhost:8080 npm install --registry http://registry.npmjs.org/

Python pip

With pip use the non-https version of the registry:

http_proxy=http://localhost:8080 pip install  --index-url http://pypi.python.org/simple plone

Cool guys can also set the proxy globally for everybody:

export http_proxy=http://localhost:8080

angry-caching-proxy's People

Contributors

esamattis avatar hashar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

angry-caching-proxy's Issues

SSL Support

What do we need to do to actually implement SSL support?

Trying out with gem install

Hi,

when trying it out with gem install its failing it seems on debian 7

root@debian-7:/etc/apt# http_proxy=http://xxx.xxx.xxx.xxx:8080 gem install puppet --no-ri --no-rdoc --version '> 3.4.0'
ERROR: Could not find a valid gem 'puppet' (
> 3.4.0), here is why:
Unable to download data from https://rubygems.org/ - EOFError: end of file reached (https://api.rubygems.org/specs.4.8.gz)

On Centos 6.4 its working fine. ( haven't tried out other distro's )
The Gem version ( 2.2.2 ) is the same on all of them.

Any idea's ?

Suggestion: Add config-by-environment-variable support

I want to use a forward proxy for the various package managers on my network to reduce bandwidth usage - particularly because:

  • I have a continuous integration server, which I want to look at Dockerising builds at some point
  • I build a number of Docker containers regularly

I run a cluster of Pis running Hashicorp Nomad + Consul, so I intend to Dockerise angry-caching-proxy. This isn't necessarily a problem, but it would be very nice to have the ability configure angry-caching-proxy via environment variables. This would allow me to integrate the configuration into the Dockerfile I'm writing.

This is all a long-winded way of suggesting that environment variables such as ACP_DIRECTORY, ACP_PORT, etc be used to configure angry-caching-proxy.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.