Sign inSign up

banian/cache-mirror

By banian

Updated about 7 years ago

cache-mirror

Image
1

1.2K

banian/cache-mirror repository overview

   ______           __            __  ____
  / ____/___ ______/ /_  ___     /  |/  (_)_____________  _____
 / /   / __ `/ ___/ __ \/ _ \   / /|_/ / / ___/ ___/ __ \/ ___/
/ /___/ /_/ / /__/ / / /  __/  / /  / / / /  / /  / /_/ / /
\____/\__,_/\___/_/ /_/\___/  /_/  /_/_/_/  /_/   \____/_/

A proxy cache nginx that forces the cache of resources and make conditional get request to the proxified server to check if the resource must be redownloaded. The "remote" is the proxyfied server.

Environment variables

VariableDefaultDescription
REMOTE_PROTOhttpRemote protocol
REMOTE_HOST-IP or fqdn of the remote
REMOTE_URI-Pass requests to a specific URI
CACHE_TTL5mTime to live for cached resources. Remember that invalidated cache only leads to a conditonal GET request based on If-Modified-Since header
MAX_CACHE_SIZE10g
MAX_CLIENT_CONNECTEDLimit the number of concurent connections. Return 503 to new clients if reached
CACHE_LOCK_TIMEOUT10sLock a ressource being cached in order to avoid multiple downloads
CACHE_INACTIVE3MCached data that are not accessed during the time specified by the inactive parameter get removed from the cache regardless of their freshness. (defaults to 3 month)
REWRITE_HOST-Rewrites $REMOTE_HOST value in responses with $REWRITE_HOST without changing Last-Modified
REWRITE_PROTO$REMOTE_PROTORewrites all http:// and https:// values with $REWRITE_PROTO://, only if $REWRITE_URL is set.
MODEcacheCan be either cache or store. Store is better for permanent caching.
SLICE_SIZE10mSets the size of the slice. The zero value disables splitting responses into slices. Note that a too low value may result in excessive memory usage and opening a large number of files.
LOG_MODEstdPossible values: std, persist and disabled
IMAGE(disabled)Enable image mode if value set to on
IMAGE_QUALITY85Default quality for jpeg and webp images
IMAGE_BUFFER30MMaximum size of the buffer used for reading images
IMAGE_INTERLACEonGenerate progressive images. Can be set to off

Simple Usage

docker run -it -p 8080:80 \
    -e "REMOTE_PROTO=http" \
    -e "REMOTE_HOST=registry.npmjs.org" \
    -e "CACHE_TTL=1h" \
    -e "MAX_CLIENT_CONNECTED=500" \
    -e "CACHE_LOCK_TIMEOUT=1m" \
    -v "`pwd`/cache:/data" \
    banian/cache-mirror:latest

Adding extra configurations

Simply mount your config file to /etc/nginx/proxy_extras.conf or /etc/nginx/server_extras.conf.

Image Mode

If IMAGE environment variable is set, image mode will be enabled.

IMPORTANT NOTE: This mode is only supported for cache mode (store is incompatible)

Supported Query Params
  • width
  • height
  • quality

Development

Use ./dev.sh script.

References

License

MIT - BanianHost

Tag summary

Content type

Image

Digest

Size

65.9 MB

Last updated

about 7 years ago

docker pull banian/cache-mirror