Giter Site home page Giter Site logo

rails asset hosts 404 about dragonfly HOT 17 CLOSED

markevans avatar markevans commented on August 20, 2024
rails asset hosts 404

from dragonfly.

Comments (17)

sergio-fry avatar sergio-fry commented on August 20, 2024

Dragonfly works only with one domain out of box. I think we have to find out how to configure that

from dragonfly.

demersus avatar demersus commented on August 20, 2024

Ok, thanks for confirming this. I wanted to make sure that I was not missing some configuration parameter or something. This feature is really important for me. I am working on a website that is expected to get a bunch of traffic. I trying to figure out how to speed up the user experience. Multiple asset hosts being supported is a must!

BTW: Thanks Mark for all your work on this project. Dragonfly has become my standard tool that I use in just about all my projects involving user contributed images. You have saved me so much time!

from dragonfly.

sergio-fry avatar sergio-fry commented on August 20, 2024

as asset server you can use Amazon s3. Dragonfly supports that.

from dragonfly.

markevans avatar markevans commented on August 20, 2024

Dragonfly serves up media from its own Rack server by default - not directly from S3 (though you could hand-craft urls yourself if you wanted to)
In the future it might be nice to have something like a configurable 'remote_url'.

However, dragonfly doesn't particularly know about which domain it's on, so I don't know why that wouldn't be working. I'll try and have a go doing that myself when I get the chance and figure out what's wrong.

from dragonfly.

sergio-fry avatar sergio-fry commented on August 20, 2024

Yes, it looks like passenger issue. If you'll find some new information about that, please, let us know.

Thank you!

from dragonfly.

demersus avatar demersus commented on August 20, 2024

If you would like more information about my setup:
Passenger 3 on Nginx, Ruby 1.9.2, Rails 3, Dragonfly 0.7.6

One more thing that is related: All four asset host subdomains are aliases to the same application. I can point my webrowser to media0.mydomain.com and see my app. Everything works except the images served by dragonfly. This is also true if I turn off asset hosts. The images will only show if they are served from my original domain. They will not work from any other aliased subdomain. When the images are resized, does dragonfly somehow use the domain when generating the image url hash?

from dragonfly.

maxschulze avatar maxschulze commented on August 20, 2024

Same issue here. Passenger 3 on Nginx, Ruby 1.9.2, Padrino.rb, Dragonfly 0.7.6.

It took us some hours to figure it out, because we had multiple domains pointing to the same Application. (Our production domain and an internal one for testing). This is a very critical issue.

from dragonfly.

sergio-fry avatar sergio-fry commented on August 20, 2024

My solution was to redirect all requests to "main" domain: http://goo.gl/OZ4k8

from dragonfly.

fabiotc avatar fabiotc commented on August 20, 2024

Same error here....

from dragonfly.

sergio-fry avatar sergio-fry commented on August 20, 2024

what kind of? it works for me

from dragonfly.

fabiotc avatar fabiotc commented on August 20, 2024

@sergio-fry
With redirection it works, but the URL in the browser is changed to the original website, and I don't want this behavior in my app.

from dragonfly.

demersus avatar demersus commented on August 20, 2024

@fabiotc Yes, I agree. The redirection is a hack but not a solution. The point of having the separate asset host domains is to allow simultaneous image downloading, and to load balance. It is my understanding that most browsers will not allow multiple simultaneous connections to the same host. But will to multiple hosts.

Still no solution to this? I am sorry that I do not have the time to investigate it further at this point. Is this only related to passenger? Or does it happen in other environments?

from dragonfly.

demersus avatar demersus commented on August 20, 2024

Ok, I have found the solution to this. Apparently it is an Nginx + Passenger issue. I have no clue why, or how. But by adding the following line to my routes.rb I am able to use distributed asset hosts, and also use passenger standalone in development:

match '/media/*dragonfly', :to => Dragonfly[:images]

from dragonfly.

sergio-fry avatar sergio-fry commented on August 20, 2024

Great, @demersus! is it possible to write patch for dragonfly?

from dragonfly.

demersus avatar demersus commented on August 20, 2024

We will have to spend some time tracking the exact problem. I am determined to to find it, if someone else does not. I just don't have any extra time at this point.

When I stumble across the offending code I will contribute a patch. It definitely seems to be a passenger + nginx issue. The only reason why I found the above fix is because I started using passenger standalone in development, and could not get the images to work. I found the above fix in a forum, I believe it was the google group for dragonfly, to fix the standalone version of passenger. So I decided to leave it in my routes.rb file and it fixed the problems in production as well.
I hope this solves it for you guys too. @sergio-fry, @fabiotc, and @maxschulze.
I must say it is a nice speed boost to have four hosts working on image resizing at the same time!

from dragonfly.

demersus avatar demersus commented on August 20, 2024

Also, something I wanted to share for you if you are going to make a lightbox, or link to the images. You will have to use 'compute_public_path' to force the path for the link to use the distributed asset hosts. Example:
<%= link_to image_tag(@my_model.image.thumb('50x50').url), compute_public_path(@my_model.image.thumb('800x600>').url, "") %>

This will generate a full url using your asset hosts for the linked image.

from dragonfly.

sergio-fry avatar sergio-fry commented on August 20, 2024

@demersus You are awesome! :) I'll try it out soon

from dragonfly.

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.