Skip to content

banianhost/docker-cache-mirror

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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

Variable Default Description
REMOTE_PROTO http Remote protocol
REMOTE_HOST - IP or fqdn of the remote
REMOTE_URI - Pass requests to a specific URI
CACHE_TTL 5m Time to live for cached resources. Remember that invalidated cache only leads to a conditonal GET request based on If-Modified-Since header
MAX_CACHE_SIZE 10g
MAX_CLIENT_CONNECTED Limit the number of concurent connections. Return 503 to new clients if reached
CACHE_LOCK_TIMEOUT 10s Lock a ressource being cached in order to avoid multiple downloads
CACHE_INACTIVE 3M Cached 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_PROTO Rewrites all http:// and https:// values with $REWRITE_PROTO://, only if $REWRITE_URL is set.
MODE cache Can be either cache or store. Store is better for permanent caching.
SLICE_SIZE 10m Sets 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_MODE std Possible values: std, persist and disabled
IMAGE (disabled) Enable image mode if value set to on
IMAGE_QUALITY 85 Default quality for jpeg and webp images
IMAGE_BUFFER 30M Maximum size of the buffer used for reading images
IMAGE_INTERLACE on Generate 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

About

Cache Mirror Service

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published