cactus / go-camo

A secure image proxy server
MIT License
255 stars 48 forks source link

Allow use with non-image files? #24

Closed aaronpk closed 6 years ago

aaronpk commented 6 years ago

Is there a particular reason this is limited to image files? I am using it on a service where I also proxy video files. It was easiest for me to disable the check for the image header and allow anything through. It might be nice if this was a config option to either allow proxying anything, or lock down by type.

dropwhile commented 6 years ago

go-camo was indeed originally intended to proxy only images, for two reasons: 1) the camo project it was inspired by only proxied images 2) my use-case at the time only required proxying of images

Later, a fork was created by a user to additionally proxy fonts and css. I wasn't comfortable including those in go-camo -- see discussion on https://github.com/cactus/go-camo/issues/20.

In my experience, video files are "usually" either linked (by url, no content warning), uploaded (service hosts it, so no content warning), or inlined from some hosting service (eg. youtube, vimeo; ssl provided by service). Video files are also generally much larger than image content.

Can you further describe your use-case/requirements for proxying video?

aaronpk commented 6 years ago

Ah, I can see why css/js could be an issue for some uses.

I'm using this on the server side of my new social reader application so that all image/video URLs presented to the reader apps are https and from the same origin. The videos come from either Instagram, Twitter, or peoples' own blogs hosting video files directly. Because the majority of the content is twitter-like short posts, the video files are normally always under a minute long so they aren't actually that big.

dropwhile commented 6 years ago

I am tentatively considering adding a cli flag to allow a few additional content types (like video/*).
If I do decide to add it, images only will certainly be the default.

aaronpk commented 6 years ago

While you're at it, a command line flag to change the maximum allowed file size would also be appreciated! I am running into that limit now with proxying some video files.

dropwhile commented 6 years ago

@aaronpk there already happens to be a flag for max size.

From the -h help output:

      --max-size=      Max response image size (KB) (default: 5120)

Note: The size is specified in Kilobytes (KB), with the default being 5120KB == 5MB.

dropwhile commented 6 years ago

I have a branch up allow-video, with the new flag --allow-content-video.

Note: I haven't been able to test it much, as the current system I use it on wouldn't allow this additional functionality. If you have time to test it, let me know.

dropwhile commented 6 years ago

should be closed by https://github.com/cactus/go-camo/commit/a92ce5e48744df976930bba368089a6d39f58cd7