GithubHelp home page GithubHelp logo

Comments (3)

DarthSim avatar DarthSim commented on May 24, 2024

Hey @diegoatpitch!

Could you provide a use case for this feature?

from imgproxy.

diegoatpitch avatar diegoatpitch commented on May 24, 2024

The main use case is to reduce our CDN billing in a single shot.
Image sizes are calculated dynamically and on the client side. Sometimes we have some unnecessarily large images being requested.
We also are in a unique situation where we can't force all users to newer versions of the software, so adding this limit to client side would take at least 6 months to reach 90% of all of our requests.

Since this would be a server side configuration option it would help mitigate possible DoS attacks on instances without signature. I know this is not the ideal security scenario, but for us would help a great deal with mitigation.

from imgproxy.

DarthSim avatar DarthSim commented on May 24, 2024

We received a similar request some time ago. We didn't move forward with it because it does not actually prevent DoS attacks: imgproxy has a few processing options besides width and height that can be used for DoS.

We were in the same situation as you when developing our website. We have a demo on our website that allows you to resize an image and apply filters dynamically, thus we can't rely on pre-generated URLs. So we made an API that generates and signs imgproxy URLs based on the provided options. That API also checks the provided options so they match the restrictions. I would offer you to use the same approach.

Since we need to show the imgproxy URL on our site, our API just returns the URL, but you can make it to make a redirect. The API is very simple and responds in a millisecond while running on the smallest GCR instance.

The difference between our cases is that our API requires width and height to be provided while in your case, as far as I understood, it is not required. In this case, I'd offer to use a default preset: default=width:8000/height:8000. This should work because of two things:

  1. The default preset is always applied before the processing options from the URL.
  2. When the enlarge option is not used, imgproxy doesn't enlarge images, so the width and height options here will be treated as "maximum width" and maximum height. Of course, these options can be overwritten by the URL, but your API will take care of this.

The API is so simple that I could build a draft of it with a language I am familiar with if you like.

from imgproxy.

Related Issues (20)

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.