mirror of
https://github.com/willnorris/imageproxy.git
synced 2026-05-29 22:05:12 +02:00
deprecate cacheSize flag and remove docs
this flag was never actually doing what I thought it was in the first place. Also fix up a few instances of cacheDir still be used in config files fixes #45
This commit is contained in:
parent
355a00f7b6
commit
810ecedd69
4 changed files with 11 additions and 12 deletions
13
README.md
13
README.md
|
|
@ -149,19 +149,20 @@ enabled using the `-cache` flag. It supports the following values:
|
||||||
- `memory` - uses an in-memory cache. (This can exhaust your system's
|
- `memory` - uses an in-memory cache. (This can exhaust your system's
|
||||||
available memory and is not recommended for production systems)
|
available memory and is not recommended for production systems)
|
||||||
- directory on local disk (e.g. `/tmp/imageproxy`) - will cache images
|
- directory on local disk (e.g. `/tmp/imageproxy`) - will cache images
|
||||||
on disk, limited to the size specified in the `-cacheSize` flag.
|
on disk
|
||||||
- s3 URL (e.g. `s3://s3-us-west-2.amazonaws.com/my-bucket`) - will cache
|
- s3 URL (e.g. `s3://s3-us-west-2.amazonaws.com/my-bucket`) - will cache
|
||||||
images on Amazon S3. This requires either an IAM role and instance profile
|
images on Amazon S3. This requires either an IAM role and instance profile
|
||||||
with access to your your bucket or `AWS_ACCESS_KEY_ID` and `AWS_SECRET_KEY`
|
with access to your your bucket or `AWS_ACCESS_KEY_ID` and `AWS_SECRET_KEY`
|
||||||
environmental parameters set.
|
environmental parameters set.
|
||||||
|
|
||||||
For example, to cache files on disk, allowing up to 100MB of space:
|
For example, to cache files on disk in the `/tmp/imageproxy` directory:
|
||||||
|
|
||||||
imageproxy -cache /tmp/imageproxy -cacheSize 100
|
imageproxy -cache /tmp/imageproxy
|
||||||
|
|
||||||
Reload the [codercat URL][], and then inspect the contents of
|
Reload the [codercat URL][], and then inspect the contents of
|
||||||
`/tmp/imageproxy`. There should be two files there, one for the original
|
`/tmp/imageproxy`. Within the subdirectories, there should be two files, one
|
||||||
full-size codercat image, and one for the resized 500px version.
|
for the original full-size codercat image, and one for the resized 500px
|
||||||
|
version.
|
||||||
|
|
||||||
[codercat URL]: http://localhost:8080/500/https://octodex.github.com/images/codercat.jpg
|
[codercat URL]: http://localhost:8080/500/https://octodex.github.com/images/codercat.jpg
|
||||||
|
|
||||||
|
|
@ -169,7 +170,7 @@ full-size codercat image, and one for the resized 500px version.
|
||||||
|
|
||||||
You can limit images to only be accessible for certain hosts in the HTTP
|
You can limit images to only be accessible for certain hosts in the HTTP
|
||||||
referrer header, which can help prevent others from hotlinking to images. It can
|
referrer header, which can help prevent others from hotlinking to images. It can
|
||||||
be enabled be running:
|
be enabled by running:
|
||||||
|
|
||||||
imageproxy -referrers example.com
|
imageproxy -referrers example.com
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ var referrers = flag.String("referrers", "", "comma separated list of allowed re
|
||||||
var baseURL = flag.String("baseURL", "", "default base URL for relative remote URLs")
|
var baseURL = flag.String("baseURL", "", "default base URL for relative remote URLs")
|
||||||
var cache = flag.String("cache", "", "location to cache images (see https://github.com/willnorris/imageproxy#cache)")
|
var cache = flag.String("cache", "", "location to cache images (see https://github.com/willnorris/imageproxy#cache)")
|
||||||
var cacheDir = flag.String("cacheDir", "", "(Deprecated; use 'cache' instead) directory to use for file cache")
|
var cacheDir = flag.String("cacheDir", "", "(Deprecated; use 'cache' instead) directory to use for file cache")
|
||||||
var cacheSize = flag.Uint64("cacheSize", 100, "maximum size of file cache (in MB)")
|
var cacheSize = flag.Uint64("cacheSize", 0, "Deprecated: this flag does nothing")
|
||||||
var signatureKey = flag.String("signatureKey", "", "HMAC key used in calculating request signatures")
|
var signatureKey = flag.String("signatureKey", "", "HMAC key used in calculating request signatures")
|
||||||
var scaleUp = flag.Bool("scaleUp", false, "allow images to scale beyond their original dimensions")
|
var scaleUp = flag.Bool("scaleUp", false, "allow images to scale beyond their original dimensions")
|
||||||
var version = flag.Bool("version", false, "print version information")
|
var version = flag.Bool("version", false, "print version information")
|
||||||
|
|
@ -133,8 +133,7 @@ func parseCache() (imageproxy.Cache, error) {
|
||||||
|
|
||||||
func diskCache(path string) *diskcache.Cache {
|
func diskCache(path string) *diskcache.Cache {
|
||||||
d := diskv.New(diskv.Options{
|
d := diskv.New(diskv.Options{
|
||||||
BasePath: path,
|
BasePath: path,
|
||||||
CacheSizeMax: *cacheSize * 1024 * 1024,
|
|
||||||
|
|
||||||
// For file "c0ffee", store file as "c0/ff/c0ffee"
|
// For file "c0ffee", store file as "c0/ff/c0ffee"
|
||||||
Transform: func(s string) []string { return []string{s[0:2], s[2:4]} },
|
Transform: func(s string) []string { return []string{s[0:2], s[2:4]} },
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,7 @@ case "$1" in
|
||||||
. /etc/default/imageproxy
|
. /etc/default/imageproxy
|
||||||
|
|
||||||
test -n "$ADDR" && DAEMON_OPTS+=" -addr=$ADDR"
|
test -n "$ADDR" && DAEMON_OPTS+=" -addr=$ADDR"
|
||||||
test -n "$CACHE_DIR" && DAEMON_OPTS+=" -cacheDir=$CACHE_DIR"
|
test -n "$CACHE" && DAEMON_OPTS+=" -cache=$CACHE"
|
||||||
test -n "$CACHE_SIZE" && DAEMON_OPTS+=" -cacheSize=$CACHE_SIZE"
|
|
||||||
test -n "$LOG_DIR" && DAEMON_OPTS+=" -log_dir=$LOG_DIR"
|
test -n "$LOG_DIR" && DAEMON_OPTS+=" -log_dir=$LOG_DIR"
|
||||||
test -n "$ALLOWED_REMOTE_HOSTS" && DAEMON_OPTS+=" -whitelist=$ALLOWED_REMOTE_HOSTS"
|
test -n "$ALLOWED_REMOTE_HOSTS" && DAEMON_OPTS+=" -whitelist=$ALLOWED_REMOTE_HOSTS"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ respawn
|
||||||
exec start-stop-daemon --start -c www-data --exec /usr/bin/imageproxy -- \
|
exec start-stop-daemon --start -c www-data --exec /usr/bin/imageproxy -- \
|
||||||
-addr localhost:4593 \
|
-addr localhost:4593 \
|
||||||
-log_dir /var/log/imageproxy \
|
-log_dir /var/log/imageproxy \
|
||||||
-cacheDir /var/cache/imageproxy \
|
-cache /var/cache/imageproxy \
|
||||||
-signatureKey @/etc/imageproxy.key \
|
-signatureKey @/etc/imageproxy.key \
|
||||||
-baseURL https://willnorris.com/ \
|
-baseURL https://willnorris.com/ \
|
||||||
-whitelist willnorris.com,notsoserendipitous.com,gabenorris.com
|
-whitelist willnorris.com,notsoserendipitous.com,gabenorris.com
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue