Giter Site home page Giter Site logo

renuo-thumbs-proxy's Introduction

Renuo Thumbs Proxy

Renuo thumbs proxy is an app to sign images so they are processed by thumbor. You can restrict the source of the images by setting the BACKEND_IMAGES_PATH (e.g. ao3ief5j.cloudfront.com), so only images from this domain / path are processed by thumbor.

Deployment

The app is ready to run on heroku. Create a new heroku app, set the env variables, and push the code to Heroku.

Performance / Requests per Second

With the default heroku host (1 dyno for the proxy, 1 dyno for thumbor), about 20 rps are possible.

Installation and Usage

pyenv install 3.6.10
  • Install virtualenvwrapper

Make sure that this has been added to your environment (e.g. .zshrc):

eval "$(pyenv init - zsh)"
eval "$(pyenv virtualenv-init -)"

Clone the project, setup virtualenv and install dependencies:

git clone [email protected]:renuo/renuo-thumbs-proxy.git
cd renuo-thumbs-proxy
pyenv virtualenv 3.6.10 renuo-thumbs-proxy-3.6.10
pip install -r requirements.txt
pyenv rehash
  • cp local_server.example.sh local_server.sh
  • Adjust config for local_server.sh
THUMBOR_SECURITY_KEY=UJwHAZLsRejTyLI88lAriHL7xAXa6q0umiwwpPcP \
 BACKEND_ASSET_PATH=ao3ief5j.cloudfront.com \
 THUMBOR_PATH=thumbor.example.com \
 DEBUG=True \
 python server.py
  • Create a backend and upload images (e.g. S3)
  • Make the images accessible (e.g. Cloudfront)
    • From this step, you will get the BACKEND_ASSET_PATH, e.g. ao3ief5j.cloudfront.com
  • Generate a THUMBOR_SECURITY_KEY, configure thumbor
  • Transform images calling the right url (/thumb/path:config/u/path:uri)
    • Example: /thumb/200x300/smart/u/images/logo.png

Config

The configuration is done by setting environment variables.

Example:

THUMBOR_SECURITY_KEY=UJwHAZLsRejTyLI88lAriHL7xAXa6q0umiwwpPcP
BACKEND_ASSET_PATH=ao3ief5j.cloudfront.com
SENTRY_DSN= http://public:[email protected]/1

THUMBOR_SECURITY_KEY

The THUMBOR_SECURITY_KEY is a shared key (proxy and thumbor app) to validate that the image can be processed by thumbor.

In thumbor this key is called SECURITY_KEY. See also: https://github.com/thumbor/thumbor/wiki/Security

Generate it randomly, and keep it secret (only shared with the thumbor app).

Example: UJwHAZLsRejTyLI88lAriHL7xAXa6q0umiwwpPcP

BACKEND_IMAGES_PATH

The BACKEND_IMAGES_PATH is the host and the path from which the assets are downloaded. E.g. if you want to resize images from the site https://www.renuo.ch, e.g. https://www.renuo.ch/images/logo.png then you can define

  1. the BACKEND_IMAGES_PATH to "www.renuo.ch", and then make a request to images/logo.png
  2. the BACKEND_IMAGES_PATH to "www.renuo.ch/images", and then make a request to logo.png

Don't leave it blank. Don't use http:// or https:// in the path.

THUMBOR_PATH

This is the path to your thumbor server.

Example: thumbor.example.com

SENTRY_DSN

For monitoring the app, we use Sentry.

Example: http://public:[email protected]/1

DEBUG

Optional.

Example: True

Design Decisions

  • Use HTTPS everywhere
  • Have only one host to serve images which should be resized
  • Have one thumbor instance which resizes images

Renuo Thumbor

See https://github.com/renuo/renuo-thumbor

renuo-thumbs-proxy's People

Contributors

lukaselmer avatar sihu avatar schmijos avatar lukasbischof avatar pandermatt avatar

Stargazers

Luiz Boaretto avatar  avatar

Watchers

Stéphane Bisinger avatar Mike avatar James Cloos avatar Alessandro Rodi avatar Samuel Steiner avatar Cyril Kyburz avatar Zora Fuchs avatar amina avatar Alicia Rüegg avatar  avatar

Forkers

shyp lukaselmer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.