Our users can use images from external domains on LinuxFr.org. This component is a reverse-proxy / cache for these images.
Th main benefits of using a proxy instead of linking directly the images are:
- No flood: images can be hosted on small servers that are not able to handle all the traffic from LinuxFr.org, so we avoid to flood them
- History: even if a server is taken down, we are able to keep serving images that are already used on our pages
- Security: on the HTTPS pages, we won't include images from other domains that are available only in HTTP, so it prevents browsers from displaying warning about unsafe pages
- Privacy: the users won't connect to the external domains, so their IP addresses won't be logged on these servers.
Install Go and don't forget to set $GOPATH
$ go get -v -u github.com/linuxfrorg/img-LinuxFr.org
$ img-LinuxFr.org [-a addr] [-r redis] [-l log] [-d dir]
And, to display the help:
$ img-LinuxFr.org -h
Build and run Docker image:
$ docker build -t img-linuxfr.org .
$ docker run --publish 8000:8000 img-linuxfr.org
or
$ docker run --publish 8000:8000 --env REDIS=someredis:6379/1 img-linuxfr.org
Github has developed a similar service, camo, for their own usage. I used it as a source of inspiration but I prefered to redevelop a new service instead of using it for several reasons:
- It lacks some feature and particulary caching!
- It runs with a legacy version of node.js, which is not very friendly for our sysadmins.
- I plan to extend it for other usages in the future, and I prefer coding in golang than in nodejs.
- And it's a fun component to recode :p
The code is licensed as GNU AGPLv3. See the LICENSE file for the full license.
♡2012 by Bruno Michel. Copying is an act of love. Please copy and share.