README,docs: format and update URLs

Format docs with prettier. Update godoc.org URLs to pkg.go.dev.
This commit is contained in:
Will Norris 2025-04-30 23:32:32 -07:00
parent 7502adde1c
commit 8170536e41
5 changed files with 313 additions and 265 deletions

View file

@ -1,314 +1,360 @@
# Changelog
This file contains all notable changes to
[imageproxy](https://github.com/willnorris/imageproxy). The format is based on
[imageproxy](https://github.com/willnorris/imageproxy). The format is based on
[Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
[Unreleased]: https://github.com/willnorris/imageproxy/compare/v0.9.0...HEAD
## [0.10.0] (2020-04-02)
[0.10.0]: https://github.com/willnorris/imageproxy/compare/v0.9.0...v0.10.0
### Added
- add support for multiple signature keys to support key rotation
([ef09c1b](https://github.com/willnorris/imageproxy/commit/ef09c1b),
[#209](https://github.com/willnorris/imageproxy/pull/209),
[maurociancio](https://github.com/maurociancio))
- added option to include referer header in remote requests
([#216](https://github.com/willnorris/imageproxy/issues/216))
- added basic support for recording prometheus metrics
([#121](https://github.com/willnorris/imageproxy/pull/121)
[benhaan](https://github.com/benhaan))
- add support for multiple signature keys to support key rotation
([ef09c1b](https://github.com/willnorris/imageproxy/commit/ef09c1b),
[#209](https://github.com/willnorris/imageproxy/pull/209),
[maurociancio](https://github.com/maurociancio))
- added option to include referer header in remote requests
([#216](https://github.com/willnorris/imageproxy/issues/216))
- added basic support for recording prometheus metrics
([#121](https://github.com/willnorris/imageproxy/pull/121)
[benhaan](https://github.com/benhaan))
### Fixed
- improved content type detection for some hosts, particularly S3
([ea95ad9](https://github.com/willnorris/imageproxy/commit/ea95ad9),
[shahan312](https://github.com/shahan312))
- fix signature verification for some proxied URLs
([3589510](https://github.com/willnorris/imageproxy/commit/3589510),
[#212](https://github.com/willnorris/imageproxy/issues/212),
([#215](https://github.com/willnorris/imageproxy/issues/215),
thanks to [aaronpk](https://github.com/aaronpk) for helping debug and
[fieldistor](https://github.com/fieldistor) for the suggested fix)
- improved content type detection for some hosts, particularly S3
([ea95ad9](https://github.com/willnorris/imageproxy/commit/ea95ad9),
[shahan312](https://github.com/shahan312))
- fix signature verification for some proxied URLs
([3589510](https://github.com/willnorris/imageproxy/commit/3589510),
[#212](https://github.com/willnorris/imageproxy/issues/212),
([#215](https://github.com/willnorris/imageproxy/issues/215),
thanks to [aaronpk](https://github.com/aaronpk) for helping debug and
[fieldistor](https://github.com/fieldistor) for the suggested fix)
## [0.9.0] (2019-06-10)
[0.9.0]: https://github.com/willnorris/imageproxy/compare/v0.8.0...v0.9.0
### Added
- allow request signatures to cover options
([#145](https://github.com/willnorris/imageproxy/issues/145))
- add simple imageproxy-sign tool for calculating signatures
([e1558d5](https://github.com/willnorris/imageproxy/commit/e1558d5))
- allow overriding the Logger used by Proxy
([#174](https://github.com/willnorris/imageproxy/pull/174),
[hmhealey](https://github.com/hmhealey))
- allow using environment variables for configuration
([50e0d11](https://github.com/willnorris/imageproxy/commit/50e0d11))
- add support for BMP images
([d4ba520](https://github.com/willnorris/imageproxy/commit/d4ba520))
- allow request signatures to cover options
([#145](https://github.com/willnorris/imageproxy/issues/145))
- add simple imageproxy-sign tool for calculating signatures
([e1558d5](https://github.com/willnorris/imageproxy/commit/e1558d5))
- allow overriding the Logger used by Proxy
([#174](https://github.com/willnorris/imageproxy/pull/174),
[hmhealey](https://github.com/hmhealey))
- allow using environment variables for configuration
([50e0d11](https://github.com/willnorris/imageproxy/commit/50e0d11))
- add support for BMP images
([d4ba520](https://github.com/willnorris/imageproxy/commit/d4ba520))
### Changed
- improvements to docker image: run as non-privileged user, use go1.12
compiler, and build imageproxy as a go module.
- options are now sorted when converting to string. This is a breaking change
for anyone relying on the option order, and will additionally invalidate
most cached values, since the option string is part of the cache key.
- improvements to docker image: run as non-privileged user, use go1.12
compiler, and build imageproxy as a go module.
Both the original remote image, as well as any transformations on that image
are cached, but only the transformed images will be impacted by this change.
This will result in imageproxy having to re-perform the transformations, but
should not result in re-fetching the remote image, unless it has already
otherwise expired.
- options are now sorted when converting to string. This is a breaking change
for anyone relying on the option order, and will additionally invalidate
most cached values, since the option string is part of the cache key.
Both the original remote image, as well as any transformations on that image
are cached, but only the transformed images will be impacted by this change.
This will result in imageproxy having to re-perform the transformations, but
should not result in re-fetching the remote image, unless it has already
otherwise expired.
### Fixed
- properly include Accept header on remote URL requests
([#165](https://github.com/willnorris/imageproxy/issues/165),
[6aca1e0](https://github.com/willnorris/imageproxy/commit/6aca1e0))
- detect response content type if content-type header is missing
([cf54b2c](https://github.com/willnorris/imageproxy/commit/cf54b2c))
- properly include Accept header on remote URL requests
([#165](https://github.com/willnorris/imageproxy/issues/165),
[6aca1e0](https://github.com/willnorris/imageproxy/commit/6aca1e0))
- detect response content type if content-type header is missing
([cf54b2c](https://github.com/willnorris/imageproxy/commit/cf54b2c))
### Removed
- removed deprecated `whitelist` flag and `Proxy.Whitelist` struct field. Use
`allowHosts` and `Proxy.AllowHosts` instead.
- removed deprecated `whitelist` flag and `Proxy.Whitelist` struct field. Use
`allowHosts` and `Proxy.AllowHosts` instead.
## [0.8.0] (2019-03-21)
[0.8.0]: https://github.com/willnorris/imageproxy/compare/v0.7.0...v0.8.0
### Added
- added support for restricting proxied URLs [based on Content-Type
headers](https://github.com/willnorris/imageproxy#allowed-content-type-list)
([#141](https://github.com/willnorris/imageproxy/pull/141),
[ccbrown](https://github.com/ccbrown))
- added ability to [deny requests](https://github.com/willnorris/imageproxy#allowed-and-denied-hosts-list)
for certain remote hosts
([#85](https://github.com/willnorris/imageproxy/pull/85),
[geriljaSA](https://github.com/geriljaSA))
- added `userAgent` flag to specify a custom user agent when fetching images
([#83](https://github.com/willnorris/imageproxy/pull/83),
[huguesalary](https://github.com/huguesalary))
- added support for [s3 compatible](https://github.com/willnorris/imageproxy#cache)
storage providers
([#147](https://github.com/willnorris/imageproxy/pull/147),
[ruledio](https://github.com/ruledio))
- log URL when image transform fails for easier debugging
([#149](https://github.com/willnorris/imageproxy/pull/149),
[daohoangson](https://github.com/daohoangson))
- added support for building imageproxy as a [go module](https://golang.org/wiki/Modules).
A future version will remove vendored dependencies, at which point building
as a module will be the only supported method of building imageproxy.
- added support for restricting proxied URLs [based on Content-Type
headers](https://github.com/willnorris/imageproxy#allowed-content-type-list)
([#141](https://github.com/willnorris/imageproxy/pull/141),
[ccbrown](https://github.com/ccbrown))
- added ability to [deny requests](https://github.com/willnorris/imageproxy#allowed-and-denied-hosts-list)
for certain remote hosts
([#85](https://github.com/willnorris/imageproxy/pull/85),
[geriljaSA](https://github.com/geriljaSA))
- added `userAgent` flag to specify a custom user agent when fetching images
([#83](https://github.com/willnorris/imageproxy/pull/83),
[huguesalary](https://github.com/huguesalary))
- added support for [s3 compatible](https://github.com/willnorris/imageproxy#cache)
storage providers
([#147](https://github.com/willnorris/imageproxy/pull/147),
[ruledio](https://github.com/ruledio))
- log URL when image transform fails for easier debugging
([#149](https://github.com/willnorris/imageproxy/pull/149),
[daohoangson](https://github.com/daohoangson))
- added support for building imageproxy as a [go module](https://golang.org/wiki/Modules).
A future version will remove vendored dependencies, at which point building
as a module will be the only supported method of building imageproxy.
### Changed
- when a remote URL is denied, return a generic error message that does not specify exactly why it failed
([7e19b5c](https://github.com/willnorris/imageproxy/commit/7e19b5c))
- when a remote URL is denied, return a generic error message that does not specify exactly why it failed
([7e19b5c](https://github.com/willnorris/imageproxy/commit/7e19b5c))
### Deprecated
- `whitelist` flag and `Proxy.Whitelist` struct field renamed to `allowHosts`
and `Proxy.AllowHosts`. Old values are still supported, but will be removed
in a future release.
- `whitelist` flag and `Proxy.Whitelist` struct field renamed to `allowHosts`
and `Proxy.AllowHosts`. Old values are still supported, but will be removed
in a future release.
### Fixed
- fixed tcp_mem resource leak on 304 responses
([#153](https://github.com/willnorris/imageproxy/pull/153),
[Micr0mega](https://github.com/Micr0mega))
- fixed tcp_mem resource leak on 304 responses
([#153](https://github.com/willnorris/imageproxy/pull/153),
[Micr0mega](https://github.com/Micr0mega))
## [0.7.0] (2018-02-06)
[0.7.0]: https://github.com/willnorris/imageproxy/compare/v0.6.0...v0.7.0
### Added
- added support for arbitrary [rectangular crops](https://godoc.org/willnorris.com/go/imageproxy#hdr-Rectangle_Crop)
([#90](https://github.com/willnorris/imageproxy/pull/90),
[maciejtarnowski](https://github.com/maciejtarnowski))
- added support for tiff images
([#109](https://github.com/willnorris/imageproxy/pull/109),
[mikecx](https://github.com/mikecx))
- added support for additional [caching backends](https://github.com/willnorris/imageproxy#cache):
- Google Cloud Storage
([#106](https://github.com/willnorris/imageproxy/pull/106),
[diegomarangoni](https://github.com/diegomarangoni))
- Azure
([#79](https://github.com/willnorris/imageproxy/pull/79),
[PaulARoy](https://github.com/PaulARoy))
- Redis
([#49](https://github.com/willnorris/imageproxy/issues/49)
[dbfc693](https://github.com/willnorris/imageproxy/commit/dbfc693))
- Tiering multiple caches by repeating the `-cache` flag
([ec5b543](https://github.com/willnorris/imageproxy/commit/ec5b543))
- added support for EXIF orientation tags
([#63](https://github.com/willnorris/imageproxy/issues/63),
[67619a6](https://github.com/willnorris/imageproxy/commit/67619a6))
- added [smart crop feature](https://godoc.org/willnorris.com/go/imageproxy#hdr-Smart_Crop)
([#55](https://github.com/willnorris/imageproxy/issues/55),
[afbd254](https://github.com/willnorris/imageproxy/commit/afbd254))
- added support for arbitrary [rectangular crops](https://godoc.org/willnorris.com/go/imageproxy#hdr-Rectangle_Crop)
([#90](https://github.com/willnorris/imageproxy/pull/90),
[maciejtarnowski](https://github.com/maciejtarnowski))
- added support for tiff images
([#109](https://github.com/willnorris/imageproxy/pull/109),
[mikecx](https://github.com/mikecx))
- added support for additional [caching backends](https://github.com/willnorris/imageproxy#cache):
- Google Cloud Storage
([#106](https://github.com/willnorris/imageproxy/pull/106),
[diegomarangoni](https://github.com/diegomarangoni))
- Azure
([#79](https://github.com/willnorris/imageproxy/pull/79),
[PaulARoy](https://github.com/PaulARoy))
- Redis
([#49](https://github.com/willnorris/imageproxy/issues/49)
[dbfc693](https://github.com/willnorris/imageproxy/commit/dbfc693))
- Tiering multiple caches by repeating the `-cache` flag
([ec5b543](https://github.com/willnorris/imageproxy/commit/ec5b543))
- added support for EXIF orientation tags
([#63](https://github.com/willnorris/imageproxy/issues/63),
[67619a6](https://github.com/willnorris/imageproxy/commit/67619a6))
- added [smart crop feature](https://godoc.org/willnorris.com/go/imageproxy#hdr-Smart_Crop)
([#55](https://github.com/willnorris/imageproxy/issues/55),
[afbd254](https://github.com/willnorris/imageproxy/commit/afbd254))
### Changed
- rotate values are normalized, such that `r-90` is the same as `r270`
([07c54b4](https://github.com/willnorris/imageproxy/commit/07c54b4))
- now return `200 OK` response for requests to root `/`
([5ee7e28](https://github.com/willnorris/imageproxy/commit/5ee7e28))
- switch to using official AWS Go SDK for s3 cache storage. This is a
breaking change for anyone using that cache implementation, since the URL
syntax has changed. This adds support for the newer v4 auth method, as well
as additional s3 regions.
([0ee5167](https://github.com/willnorris/imageproxy/commit/0ee5167))
- switched to standard go log library. Added `-verbose` flag for more logging
in-memory cache backend supports limiting the max cache size
([a57047f](https://github.com/willnorris/imageproxy/commit/a57047f))
- docker image sized reduced by using scratch image and multistage build
([#113](https://github.com/willnorris/imageproxy/pull/113),
[matematik7](https://github.com/matematik7))
- rotate values are normalized, such that `r-90` is the same as `r270`
([07c54b4](https://github.com/willnorris/imageproxy/commit/07c54b4))
- now return `200 OK` response for requests to root `/`
([5ee7e28](https://github.com/willnorris/imageproxy/commit/5ee7e28))
- switch to using official AWS Go SDK for s3 cache storage. This is a
breaking change for anyone using that cache implementation, since the URL
syntax has changed. This adds support for the newer v4 auth method, as well
as additional s3 regions.
([0ee5167](https://github.com/willnorris/imageproxy/commit/0ee5167))
- switched to standard go log library. Added `-verbose` flag for more logging
in-memory cache backend supports limiting the max cache size
([a57047f](https://github.com/willnorris/imageproxy/commit/a57047f))
- docker image sized reduced by using scratch image and multistage build
([#113](https://github.com/willnorris/imageproxy/pull/113),
[matematik7](https://github.com/matematik7))
### Removed
- removed deprecated `cacheDir` and `cacheSize` flags
- removed deprecated `cacheDir` and `cacheSize` flags
### Fixed
- fixed interpretation of `Last-Modified` and `If-Modified-Since` headers
([#108](https://github.com/willnorris/imageproxy/pull/108),
[jamesreggio](https://github.com/jamesreggio))
- preserve original URL encoding
([#115](https://github.com/willnorris/imageproxy/issues/115))
- fixed interpretation of `Last-Modified` and `If-Modified-Since` headers
([#108](https://github.com/willnorris/imageproxy/pull/108),
[jamesreggio](https://github.com/jamesreggio))
- preserve original URL encoding
([#115](https://github.com/willnorris/imageproxy/issues/115))
## [0.6.0] (2017-08-29)
[0.6.0]: https://github.com/willnorris/imageproxy/compare/v0.5.1...v0.6.0
### Added
- added health check endpoint
([#54](https://github.com/willnorris/imageproxy/pull/54),
[immunda](https://github.com/immunda))
- preserve Link headers from remote image
([#68](https://github.com/willnorris/imageproxy/pull/68),
[xavren](https://github.com/xavren))
- added support for per-request timeout
([#75](https://github.com/willnorris/imageproxy/issues/75))
- added support for specifying output image format
([b9cc9df](https://github.com/willnorris/imageproxy/commit/b9cc9df))
- added webp support (decode only)
([3280445](https://github.com/willnorris/imageproxy/commit/3280445))
- added CORS support
([#96](https://github.com/willnorris/imageproxy/pull/96),
[romdim](https://github.com/romdim))
- added health check endpoint
([#54](https://github.com/willnorris/imageproxy/pull/54),
[immunda](https://github.com/immunda))
- preserve Link headers from remote image
([#68](https://github.com/willnorris/imageproxy/pull/68),
[xavren](https://github.com/xavren))
- added support for per-request timeout
([#75](https://github.com/willnorris/imageproxy/issues/75))
- added support for specifying output image format
([b9cc9df](https://github.com/willnorris/imageproxy/commit/b9cc9df))
- added webp support (decode only)
([3280445](https://github.com/willnorris/imageproxy/commit/3280445))
- added CORS support
([#96](https://github.com/willnorris/imageproxy/pull/96),
[romdim](https://github.com/romdim))
### Fixed
- improved error messages for some authorization failures
([27d5378](https://github.com/willnorris/imageproxy/commit/27d5378))
- skip transformation when not needed
([#64](https://github.com/willnorris/imageproxy/issues/64))
- properly handled "cleaned" remote URLs
([a1af9aa](https://github.com/willnorris/imageproxy/commit/a1af9aa),
[b61992e](https://github.com/willnorris/imageproxy/commit/b61992e))
- improved error messages for some authorization failures
([27d5378](https://github.com/willnorris/imageproxy/commit/27d5378))
- skip transformation when not needed
([#64](https://github.com/willnorris/imageproxy/issues/64))
- properly handled "cleaned" remote URLs
([a1af9aa](https://github.com/willnorris/imageproxy/commit/a1af9aa),
[b61992e](https://github.com/willnorris/imageproxy/commit/b61992e))
## [0.5.1] (2015-12-07)
[0.5.1]: https://github.com/willnorris/imageproxy/compare/v0.5.0...v0.5.1
### Fixed
- fixed bug in gif resizing
([gifresize@104a7cd](https://github.com/willnorris/gifresize/commit/104a7cd))
- fixed bug in gif resizing
([gifresize@104a7cd](https://github.com/willnorris/gifresize/commit/104a7cd))
## [0.5.0] (2015-12-07)
[0.5.0]: https://github.com/willnorris/imageproxy/compare/v0.4.0...v0.5.0
## Added
- added Dockerfile
([#29](https://github.com/willnorris/imageproxy/pull/29),
[sevki](https://github.com/sevki))
- allow scaling image beyond its original size with `-scaleUp` flag
([#37](https://github.com/willnorris/imageproxy/pull/37),
[runemadsen](https://github.com/runemadsen))
- add ability to restrict HTTP referrer
([9213c93](https://github.com/willnorris/imageproxy/commit/9213c93),
[connor4312](https://github.com/connor4312))
- preserve cache-control header from remote image
([#43](https://github.com/willnorris/imageproxy/pull/43),
[runemadsen](https://github.com/runemadsen))
- add support for caching images on Amazon S3
([ec96fcb](https://github.com/willnorris/imageproxy/commit/ec96fcb)
[victortrac](https://github.com/victortrac))
- added Dockerfile
([#29](https://github.com/willnorris/imageproxy/pull/29),
[sevki](https://github.com/sevki))
- allow scaling image beyond its original size with `-scaleUp` flag
([#37](https://github.com/willnorris/imageproxy/pull/37),
[runemadsen](https://github.com/runemadsen))
- add ability to restrict HTTP referrer
([9213c93](https://github.com/willnorris/imageproxy/commit/9213c93),
[connor4312](https://github.com/connor4312))
- preserve cache-control header from remote image
([#43](https://github.com/willnorris/imageproxy/pull/43),
[runemadsen](https://github.com/runemadsen))
- add support for caching images on Amazon S3
([ec96fcb](https://github.com/willnorris/imageproxy/commit/ec96fcb)
[victortrac](https://github.com/victortrac))
## Changed
- change default cache to none, and add `-cache` flag for specifying caches.
This deprecates the `-cacheDir` flag.
- on-disk cache now stores files in a two-level trie. For example, for a file
named "c0ffee", store file as "c0/ff/c0ffee".
- change default cache to none, and add `-cache` flag for specifying caches.
This deprecates the `-cacheDir` flag.
- on-disk cache now stores files in a two-level trie. For example, for a file
named "c0ffee", store file as "c0/ff/c0ffee".
## Fixed
- skip resizing if requested dimensions larger than original
([#46](https://github.com/willnorris/imageproxy/pull/46),
[orian](https://github.com/orian))
- skip resizing if requested dimensions larger than original
([#46](https://github.com/willnorris/imageproxy/pull/46),
[orian](https://github.com/orian))
## [0.4.0] (2015-05-21)
[0.4.0]: https://github.com/willnorris/imageproxy/compare/v0.3.0...v0.4.0
### Added
- added support for animated gifs
([#23](https://github.com/willnorris/imageproxy/issues/23))
- added support for animated gifs
([#23](https://github.com/willnorris/imageproxy/issues/23))
### Changed
- non-200 responses from remote servers are proxied as-is
- non-200 responses from remote servers are proxied as-is
## [0.3.0] (2015-12-07)
[0.3.0]: https://github.com/willnorris/imageproxy/compare/v0.2.3...v0.3.0
### Added
- added support for signing requests using a sha-256 HMAC.
([a9efefc](https://github.com/willnorris/imageproxy/commit/a9efefc))
- more complete logging of requests and whether response is from the cache
([#17](https://github.com/willnorris/imageproxy/issues/17))
- added support for a base URL for remote images. This allows shorter relative
URLs to be specified in requests.
([#15](https://github.com/willnorris/imageproxy/issues/15))
- added support for signing requests using a sha-256 HMAC.
([a9efefc](https://github.com/willnorris/imageproxy/commit/a9efefc))
- more complete logging of requests and whether response is from the cache
([#17](https://github.com/willnorris/imageproxy/issues/17))
- added support for a base URL for remote images. This allows shorter relative
URLs to be specified in requests.
([#15](https://github.com/willnorris/imageproxy/issues/15))
### Fixed
- be more precise in copying over all headers from remote image response
([1bf0515](https://github.com/willnorris/imageproxy/commit/1bf0515))
- be more precise in copying over all headers from remote image response
([1bf0515](https://github.com/willnorris/imageproxy/commit/1bf0515))
## [0.2.3] (2015-02-20)
[0.2.3]: https://github.com/willnorris/imageproxy/compare/v0.2.2...v0.2.3
### Added
- added quality option
([#13](https://github.com/willnorris/imageproxy/pull/13)
[cubabit](https://github.com/cubabit))
- added quality option
([#13](https://github.com/willnorris/imageproxy/pull/13)
[cubabit](https://github.com/cubabit))
## [0.2.2] (2014-12-08)
[0.2.2]: https://github.com/willnorris/imageproxy/compare/v0.2.1...v0.2.2
### Added
- added `cacheSize` flag to command line
- added `cacheSize` flag to command line
### Changed
- improved documentation and error messages
- negative width or height transformation values interpreted as 0
- improved documentation and error messages
- negative width or height transformation values interpreted as 0
## [0.2.1] (2014-08-13)
[0.2.1]: https://github.com/willnorris/imageproxy/compare/v0.2.0...v0.2.1
### Changed
- restructured package so that the command line tools is now installed from
`willnorris.com/go/imageproxy/cmd/imageproxy`
- restructured package so that the command line tools is now installed from
`willnorris.com/go/imageproxy/cmd/imageproxy`
## [0.2.0] (2014-07-02)
[0.2.0]: https://github.com/willnorris/imageproxy/compare/v0.1.0...v0.2.0
### Added
- transformed images are cached in addition to the original image
([#1](https://github.com/willnorris/imageproxy/issues/1))
- support etag and last-modified headers on incoming requests
([#3](https://github.com/willnorris/imageproxy/issues/3))
- support wildcards in list of allowed hosts
- transformed images are cached in addition to the original image
([#1](https://github.com/willnorris/imageproxy/issues/1))
- support etag and last-modified headers on incoming requests
([#3](https://github.com/willnorris/imageproxy/issues/3))
- support wildcards in list of allowed hosts
### Changed
- options can be specified in any order
- images cannot be resized larger than their original dimensions
- options can be specified in any order
- images cannot be resized larger than their original dimensions
## [0.1.0] (2013-12-26)
[0.1.0]: https://github.com/willnorris/imageproxy/compare/5d75e8a...v0.1.0
Initial release. Supported transformation options include:
- width and height
- different crop modes
- rotation (in 90 degree increments)
- flip (horizontal or vertical)
Initial release. Supported transformation options include:
- width and height
- different crop modes
- rotation (in 90 degree increments)
- flip (horizontal or vertical)
Images can be cached in-memory or on-disk.

View file

@ -2,7 +2,7 @@
## Types of contributions
Simple bug fixes for existing functionality are always welcome. In many cases,
Simple bug fixes for existing functionality are always welcome. In many cases,
it may be helpful to include a reproducible sample case that demonstrates the
bug being fixed.
@ -15,7 +15,7 @@ the [GitHub issue tracker](https://github.com/willnorris/imageproxy/issues).
If reporting a bug, please try and provide as much context as possible such as
what version of imageproxy you're running, what configuration options, specific
remote URLs that exhibit issues, and anything else that might be relevant to
the bug. For feature requests, please explain what you're trying to do, and
the bug. For feature requests, please explain what you're trying to do, and
how the requested feature would help you do that.
Security related bugs can either be reported in the issue tracker, or if they
@ -24,6 +24,6 @@ are more sensitive, emailed to <will@willnorris.com>.
## Code Style and Tests
Go code should follow general best practices, such as using go fmt, go lint, and
go vet (this is enforced by our continuous integration setup). Tests should
go vet (this is enforced by our continuous integration setup). Tests should
always be included where possible, especially for bug fixes in order to prevent
regressions.

View file

@ -27,7 +27,7 @@ eventually relent, and
[#49](https://github.com/willnorris/imageproxy/issues/49) tracked adding
support for the most common backends.
Unfortunately my concerns proved true, and build times are *significantly*
Unfortunately my concerns proved true, and build times are _significantly_
slower (TODO: add concrete numbers) now because of all the additional cloud
SDKs that get compiled in. I don't personally care too much about binary size,
since I'm not running in a constrained environment, but these build times are
@ -40,11 +40,12 @@ back out.
### Plugin support in Go
TODO: talk about options like
- RPC (https://github.com/hashicorp/go-plugin)
- pkg/plugin (https://golang.org/pkg/plugin/)
- embedded interpreter (https://github.com/robertkrimen/otto)
- custom binaries (https://github.com/mholt/caddy,
https://caddy.community/t/59)
- RPC (<https://github.com/hashicorp/go-plugin>)
- pkg/plugin (<https://golang.org/pkg/plugin/>)
- embedded interpreter (<https://github.com/robertkrimen/otto>)
- custom binaries (<https://github.com/mholt/caddy>,
<https://caddy.community/t/59>)
Spoiler: I'm planning on following the Caddy approach and using custom
binaries.
@ -53,21 +54,22 @@ binaries.
I plan to model imageproxy after Caddy, moving all key functionality into
separate plugins that register themselves with the server, and which all
compile to a single statically-linked binary. The core project will provide a
great number of plugins to cover all of the existing functionality. I also
compile to a single statically-linked binary. The core project will provide a
great number of plugins to cover all of the existing functionality. I also
expect I'll be much more open to adding plugins for features I may not care as
much about personally. Of course, users can also write their own plugins and
link them in without needing to contribute them to core if they don't want to.
I anticipate providing two or three build configurations in core:
- **full** - include all the plugins that are part of core (except where they
may conflict)
- **minimal** - some set of minimal features that only includes basic caching
options, limited transformation options, etc
- **my personal config** - I'll also definitely have a build that I use
personally on my site. I may decide to just make that the "minimal" build
and perhaps call it something different, rather than have a third
configuration.
- **full** - include all the plugins that are part of core (except where they
may conflict)
- **minimal** - some set of minimal features that only includes basic caching
options, limited transformation options, etc
- **my personal config** - I'll also definitely have a build that I use
personally on my site. I may decide to just make that the "minimal" build
and perhaps call it something different, rather than have a third
configuration.
Custom configurations beyond what is provided by core can be done by creating a
minimal main package that imports the plugins you care about and calling some
@ -88,7 +90,7 @@ See also issues and PRs with [label:plugins][].
This is one of the most common feature requests, and is also one of the worst
offender for inflating build times and binary sizes because of the size of the
dependencies that are typically required. The minimal imageproxy build would
dependencies that are typically required. The minimal imageproxy build would
probably only include the in-memory and on-disk caches. Anything that talked to
an external store (redis, cloud providers, etc) would be pulled out.
@ -107,9 +109,9 @@ probably wouldn't be able to interact at all).
#### Transformation options
Today, imageproxy performs minimal transformations, mostly around resizing,
cropping, and rotation. It doesn't support any kind of filters, brightness or
cropping, and rotation. It doesn't support any kind of filters, brightness or
contrast adjustment, etc. There are go libraries for them, they're just outside
the scope of what I originally intended imageproxy for. But I'd be happy to
the scope of what I originally intended imageproxy for. But I'd be happy to
have plugins that do that kind of thing. These plugins would need to be able to
hook into the option parsing engine so that they could register their URL
options.
@ -119,14 +121,14 @@ options.
There have been a number of requests for imge format support that require cgo
libraries:
- **webp encoding** - needs cgo
[#114](https://github.com/willnorris/imageproxy/issues/114)
- **progressive jpegs** - probably needs cgo?
[#77](https://github.com/willnorris/imageproxy/issues/77)
- **gif to mp4** - maybe doable in pure go, but probably belongs in a plugin
[#136](https://github.com/willnorris/imageproxy/issues/136)
- **HEIF** - formate used by newer iPhones
([HEIF](https://en.wikipedia.org/wiki/High_Efficiency_Image_File_Format))
- **webp encoding** - needs cgo
[#114](https://github.com/willnorris/imageproxy/issues/114)
- **progressive jpegs** - probably needs cgo?
[#77](https://github.com/willnorris/imageproxy/issues/77)
- **gif to mp4** - maybe doable in pure go, but probably belongs in a plugin
[#136](https://github.com/willnorris/imageproxy/issues/136)
- **HEIF** - formate used by newer iPhones
([HEIF](https://en.wikipedia.org/wiki/High_Efficiency_Image_File_Format))
#### Option parsing
@ -148,10 +150,10 @@ module](https://nginx.org/en/docs/http/ngx_http_secure_link_module.html).
### Registering Plugins
Plugins are loaded simply by importing their package. They should have an
Plugins are loaded simply by importing their package. They should have an
`init` func that calls `imageproxy.RegisterPlugin`:
``` go
```go
type Plugin struct {
}
@ -159,12 +161,12 @@ func RegisterPlugin(name string, plugin Plugin)
```
Plugins hook into various extension points of imageproxy by implementing
appropriate interfaces. A single plugin can hook into multiple parts of
appropriate interfaces. A single plugin can hook into multiple parts of
imageproxy by implementing multiple interfaces.
For example, two possible interfaces for security related plugins:
``` go
```go
// A RequestAuthorizer determines if a request is authorized to be processed.
// Requests are processed before the remote resource is retrieved.
type RequestAuthorizer interface {
@ -186,7 +188,7 @@ type ResponseAuthorizer interface {
A hypothetical interface for plugins that transform images:
``` go
```go
// An ImageTransformer transforms an image.
type ImageTransformer interface {
// TransformImage based on the provided options and return the result.

View file

@ -1,7 +1,7 @@
# How to generate signed requests
Signing requests allows an imageproxy instance to proxy images from arbitrary
remote hosts, but without opening the service up for potential abuse. When
remote hosts, but without opening the service up for potential abuse. When
appropriately configured, the imageproxy instance will only serve requests that
are for allowed hosts, or which have a valid signature.
@ -9,7 +9,7 @@ Signatures can be calculated in two ways:
1. they can be calculated solely on the remote image URL, in which case any
transformations of the image can be requested without changes to the
signature value. This used to be the only way to sign requests, but is no
signature value. This used to be the only way to sign requests, but is no
longer recommended since it still leaves the imageproxy instance open to
potential abuse.
@ -17,30 +17,30 @@ Signatures can be calculated in two ways:
the requested transformation options.
In both cases, the signature is calculated using HMAC-SHA256 and a secret key
which is provided to imageproxy on startup. The message to be signed is the
which is provided to imageproxy on startup. The message to be signed is the
remote URL, with the transformation options optionally set as the URL fragment,
[as documented below](#Signing-options). The signature is url-safe base64
[as documented below](#signing-options). The signature is url-safe base64
encoded, and [provided as an option][s-option] in the imageproxy request.
imageproxy will accept signatures for URLs with or without options
transparently. It's up to the publisher of the signed URLs to decide which
transparently. It's up to the publisher of the signed URLs to decide which
method they use to generate the URL.
[s-option]: https://godoc.org/willnorris.com/go/imageproxy#hdr-Signature
[s-option]: https://pkg.go.dev/willnorris.com/go/imageproxy#hdr-Signature-ParseOptions
## Signing options
Transformation options for a proxied URL are [specified as a comma separated
string][ParseOptions] of individual options, which can be supplied in any
order. When calculating a signature, options should be put in their canonical
order. When calculating a signature, options should be put in their canonical
form, sorted in lexigraphical order (omitting the signature option itself), and
appended to the remote URL as the URL fragment.
Currently, only [size option][] has a canonical form, which is
`{width}x{height}` with the number `0` used when no value is specified. For
`{width}x{height}` with the number `0` used when no value is specified. For
example, a request that does not request any size option would still have a
canonical size value of `0x0`, indicating that no size transformation is being
performed. If only a height of 500px is requested, the canonical form would be
performed. If only a height of 500px is requested, the canonical form would be
`0x500`.
For example, requesting the remote URL of `http://example.com/image.jpg`,
@ -57,9 +57,8 @@ the signed value would be:
The `100` size option was put in its canonical form of `100x100`, and the
options are sorted, moving `q75` before `r90`.
[ParseOptions]: https://godoc.org/willnorris.com/go/imageproxy#ParseOptions
[size option]: https://godoc.org/willnorris.com/go/imageproxy#hdr-Size_and_Cropping
[ParseOptions]: https://pkg.go.dev/willnorris.com/go/imageproxy#ParseOptions
[size option]: https://pkg.go.dev/willnorris.com/go/imageproxy#hdr-Size_and_Cropping-ParseOptions
## Signed options example
@ -76,12 +75,10 @@ and our resulting signed key is `0sR2kjyfiF1RQRj4Jm2fFa3_6SDFqdAaDEmy1oD2U-4=`
The final url would be
`http://localhost:8080/400x400,q40,s0sR2kjyfiF1RQRj4Jm2fFa3_6SDFqdAaDEmy1oD2U-4=/https://octodex.github.com/images/codercat.jpg`
## Language Examples
Here are examples of calculating signatures in a variety of languages. These
demonstrate the HMAC-SHA256 bits, but not the option canonicalization. In each
Here are examples of calculating signatures in a variety of languages. These
demonstrate the HMAC-SHA256 bits, but not the option canonicalization. In each
example, the remote URL `https://octodex.github.com/images/codercat.jpg` is
signed using a signature key of `secretkey`.
@ -90,6 +87,7 @@ See also the [imageproxy-sign tool](/cmd/imageproxy-sign).
### Go
main.go:
```go
package main
@ -180,38 +178,40 @@ url = sys.argv[2]
print base64.urlsafe_b64encode(hmac.new(key, msg=url, digestmod=hashlib.sha256).digest())
```
````shell
```shell
$ python sign.py "secretkey" "https://octodex.github.com/images/codercat.jpg"
cw34eyalj8YvpLpETxSIxv2k8QkLel2UAR5Cku2FzGM=
````
```
### JavaScript
```javascript
const crypto = require('crypto');
const URLSafeBase64 = require('urlsafe-base64');
const crypto = require("crypto");
const URLSafeBase64 = require("urlsafe-base64");
let key = process.argv[2];
let url = process.argv[3];
console.log(URLSafeBase64.encode(crypto.createHmac('sha256', key).update(url).digest()));
console.log(
URLSafeBase64.encode(crypto.createHmac("sha256", key).update(url).digest()),
);
```
````shell
```shell
$ node sign.js "secretkey" "https://octodex.github.com/images/codercat.jpg"
cw34eyalj8YvpLpETxSIxv2k8QkLel2UAR5Cku2FzGM=
````
```
### PHP
````php
```php
<?php
$key = $argv[1];
$url = $argv[2];
echo strtr(base64_encode(hash_hmac('sha256', $url, $key, 1)), '/+' , '_-');
````
```
````shell
```shell
$ php sign.php "secretkey" "https://octodex.github.com/images/codercat.jpg"
cw34eyalj8YvpLpETxSIxv2k8QkLel2UAR5Cku2FzGM=
````
```