0
Fork 0
mirror of https://github.com/willnorris/imageproxy.git synced 2024-12-16 21:56:43 -05:00
Commit graph

54 commits

Author SHA1 Message Date
Will Norris
a903995ee7 empty ContentTypes allows all types 2018-10-02 16:14:14 +00:00
Will Norris
70276f36bc rename 'Whitelist' to 'RemoteHosts"
This better describes what exactly is being allowed.
2018-09-15 05:55:02 +00:00
Will Norris
0370572130 change how content-type enforcement is handled
If no content types are specified, then accept all responses, regardless
of content type (this is the behavior imageproxy has historically had).
Change default value for the contentTypes flag to be "image/*", so that
the new default when running cmd/imageproxy is that only images will be
proxied.  The old default behavior can be achieved by passing an empty
string for the contentTypes flag:

    imageproxy -contentTypes ""

Do not send the "XCTO: nosniff" header, since all documentation that I
can find still says that it can cause problems when served with images.
If it's effectively a noop when an explicit content-type is specified in
the response, then this shouldn't actually matter for us either way.
But in the absence of certainty, I'd rather err on the side of following
the spec.

Also add documentation for the new functionality.

Fixes #141
2018-09-15 05:36:25 +00:00
Christopher Brown
39a4e1813d content-type checking 2018-09-15 04:00:34 +00:00
Wilrik
74c16f575e fixed tcp_mem resource leak when sending 304 2018-07-06 08:14:09 -07:00
Dao Hoang Son
8fc9d8876c Include image URL in transform error log message 2018-05-20 08:32:16 -07:00
James Reggio
ebcfb52f3a Fix interpretation of Last-Modified and If-Modified-Since headers
If the dates in `Last-Modified` and `If-Modified-Since` are an exact
match, the server should 304.
2017-09-23 17:01:24 -07:00
Will Norris
7338ef68ef switch from glog to standard log library
add "-verbose" flag for more logging.

fixes #105
2017-09-12 05:14:46 +00:00
Will Norris
5ee7e282cf return a 200 OK for requests to root /
This has come up a couple of times, such as in #95.  As discussed there,
I'm not completely sure this is actually necessary in many cases, but
it's certainly not harmful and if it makes health checks easier to setup
than why not?
2017-09-09 08:31:22 +00:00
Michael Carey
c1a9dab401 Support TIFF images. 2017-08-31 13:04:10 -07:00
Romanos
50f6f640b2 Enable CORS for 3rd party applications 2017-06-20 08:24:55 -07:00
Will Norris
d64b0f81c9 return 304 from TransformingTransport
If the caching headers in the request are valid, return a 304 response
instead of doing the transformation.

Ref #92
2017-06-14 20:25:56 -04:00
Will Norris
a7a04ebe7b simplify copyHeader func
- take simple http.Header values as input, rather than http.Response
- allow multiple headers to be copied to be specified.  If no headers
  specified, then copy all.
2017-06-14 17:22:45 -04:00
Will Norris
c81621ae35 rename check304 to should304
this reads a little better in if blocks
2017-06-14 16:34:34 -04:00
Will Norris
328044540e add webp support (decode only)
if any transformation is requested, webp images will be encoded and
served as jpeg or png, defaulting to jpeg if no format is specified.

Fixes #88
2017-06-01 08:13:33 -07:00
Will Norris
b9cc9df4b6 add support for specifying output image format
For now, the options are "jpeg" and "png".  Gif is a little harder to
support because of the way we use the image/gif package to handle
animated gifs. I have also have trouble imagining someone wanting to use
gif over png. But if the need really exists, we can address it when it
comes up.

Fixes #89
2017-06-01 08:13:11 -07:00
Will Norris
576b7c023a return 504 status for timeout errors
modify custom TimeoutHandler to return 504 error and switch imageproxy
to use that func.

Fixes #75
2016-11-29 15:42:08 -08:00
Will Norris
93166a5b20 add support for per-request timeout
Adds a -timeout flag for specifying the timeout.  Currently, this
returns a 503 response on timeout, though it should really be a 504,
since imageproxy is acting as a gateway.

Ref: #75
2016-11-29 15:42:07 -08:00
xavren
79369ca8ef Copy header Link for canonical image SEO
fix format
2016-06-07 13:50:07 -04:00
Will Norris
a1af9aa8e2 handle 'cleaned' remote URLs
If imageproxy runs behind an http.ServeMux or certain web servers, the
double slash in the remote URL will get collapsed down to a single
slash.  (e.g. http://example.com/ becomes http:/example.com/).  This
is now handled by imageproxy directly.

Ref #65
2016-05-26 13:22:20 -07:00
Phil Howell
1bdb3358b4 Add health-check endpoint 2016-01-12 17:19:27 +00:00
Will Norris
27d53782b4 update allowed func to return error instead of bool
this allows returning a more accurate error message, particularly in the
case of an invalid referer header
2015-12-14 10:18:14 -08:00
Will Norris
b4216d8da8 remove Proxy pointer from TransformingTransport
This pointer was only needed to pass along the scaleUp option.  In order
to prevent someone from specifying the scaleUp option on an individual
request against the owner's wishes, we didn't encode or decode that
field on the Options struct.  Instead, we stored the value on the Proxy
object and then set it on the Options struct inside the
TransformingTransport.  This worked, but I never really liked binding
those two together.

Instead, we now treat scaleUp as a normal Option field, encoding and
decoding it with all the others.  The primary difference is that the
initial value from the request URL will always be overwritten with
whatever is set in Proxy.ScaleUp.  This decouples the
TransformingTransport from the Proxy, but prevents the option from being
set in the request URL.

Modifies #37
2015-12-07 23:06:02 -08:00
Rune Madsen
9a4791d60a adding cache-control header 2015-09-05 10:51:07 -04:00
Connor Peet
9213c93c94 Add ability to restrict http referrer 2015-08-15 10:36:07 -07:00
Rune Madsen
4e60c683b0 scaleup flag 2015-08-12 14:39:38 -04:00
Will Norris
396afb8a87 proxy non-200 responses with original status code
Some sites return a 404 image, and most browsers render them properly.
We should pass them along as well.

see also: atmos/camo#75 and atmos/camo#77
2015-05-15 22:33:03 -07:00
Will Norris
a9efefc8e7 add request signature support to Proxy 2015-05-14 15:30:07 -07:00
Will Norris
9d6f8fdf7d refactor whitelist check in preparation for signature check 2015-05-14 15:30:06 -07:00
Will Norris
b1de3a9dd6 add String method to Request 2015-05-11 17:12:03 -07:00
Will Norris
ad54d71881 first pass at supporting a default base URL
this allows remote images to be specified as relative URLs, relative to
the `DefaultBaseURL` field.  Fixes #15.
2015-04-28 08:25:10 -07:00
Will Norris
dbac2f8063 log transform errors 2015-03-17 23:47:43 -07:00
Will Norris
2b84ef01ed log requests and whether response is from cache
also make sure request body is always closed

fixes #17
2015-02-24 09:34:49 -08:00
Will Norris
1bf0515cef be a little more precise in copying headers
it doesn't matter too much right now, given the headers that are being
copied, but this now makes sure that all header values get copied over
if multiple are present.
2015-02-20 23:52:52 -08:00
Will Norris
bf8d7a0cd8 copy original content-type from remote response 2015-02-20 13:05:31 -08:00
Will Norris
2e68caff67 more docs and rename TransformingTransport.Client 2014-11-26 16:49:48 -08:00
Will Norris
f476aa27c3 ignore favicon requests 2014-11-23 16:04:53 -08:00
Will Norris
2dd79ebd20 minor cleanup of error messages
- used same string for logging and error response to ensure they stay in
  sync
- pass through any http error status codes from remote URLs
2014-11-21 17:59:51 -08:00
Will Norris
5a4e602373 small cleanup of check304 and add more tests
Remove unused ResponseWriter parameter from check304, add function docs,
and add TODO for alternate Etag header values that we should handle.

Add tests for Proxy.allowed and check304.
2014-11-21 07:51:19 -08:00
Will Norris
7994cb2cf6 handle error returned when fetching remote images 2014-11-19 22:22:21 -08:00
Will Norris
dae09a8c9d rename proxy.go and remove old data package doc 2014-11-19 22:02:34 -08:00
Will Norris
a74e590181 restructure imageproxy package
- move binary from imageproxy.go to cmd/imageproxy/main.go
- move proxy package up to top level
2014-07-30 18:23:43 -07:00
Will Norris
919fdfbb78 relocate package to willnorris.com/go/imageproxy 2014-06-29 14:33:56 -07:00
Will Norris
c3eda83ab5 add default VERSION string 2013-12-26 13:55:52 -08:00
Will Norris
462b70dcc2 rename to 'imageproxy' (drop 'go-' prefix) 2013-12-26 11:14:28 -08:00
Will Norris
26dde07ec0 add -version flag and goxc build config 2013-12-26 11:00:50 -08:00
Will Norris
1db6456329 add cacheDir for specifying disk cache dir 2013-12-26 08:31:52 -08:00
Will Norris
73f6357cda rely on httpcache for response caching 2013-12-26 08:31:52 -08:00
Will Norris
ea76f2d0d8 switch to Apache 2.0 license before release 2013-12-06 17:40:35 -08:00
Will Norris
036d0c51c4 allow setting max height and width
This is primarily added to prevent a denial of service attack where
insanely large images are requested, eating up CPU.
2013-12-06 14:17:39 -08:00