I am using Dragonfly with Nginx, unicorn and mini_magick. I am using mem_cache_store in production.
Image upload and display works fine in development environment. But on production it fails with internal server error 500. I cannot see any logs on my production log, but it fails on production.
I get error for URLs of following type.
http://cdn.mydomain.com/media/BAhbB1sHOgZmSSIoMTAvcHJvZHVjdHMvMjUvR3JvdW5kJTIwbnV0XzQwOS5qcGcGOgZFVFsIOgZwOgp0aHVtYkkiCjUweDUwBjsGVA.jpg
Error code is 500
I ve been searching all the documentation which comes along with the gem. I can see the following middleware on top of the middleware stack in production as well:
use Rack::Cache
use Dragonfly::CookieMonster
use Dragonfly::Middleware
I could not get much help from forums - though there is a similar bug posted 2 years ago and is supposed to be fixed. And fixes there also did not help.
Please help to fix this. Any direction as to how I can debug this would also help.
I ran into an issue like this and turned out that the problem was that I didnt have imagemagick installed in production. This post helped me Dragonfly - Uploaded images not displayed
Btw I wasnt seeing any logs too.
You need to add:
Config.middleware.insert 0, Rack::Sendfile, config.action_dispatch.x_sendfile_header
so that sendfile is before rack:cache and it should work.
Related
This is my last resort to figure this out. I've searched through stackoverflow and googled various topics, but it seems to come down to how to interpret/analyze my own Heroku log. There's so much going on that I'm not sure where to look first. I see things like eager_load and direction to files app/config/environment:rb:5 and there also seems to be issues with my Unicorn configurations and relationship associations. I've gone through my files and haven't been able to locate what my logs are referring to, up until now it's been really easy to interpret errors.
A little background: I had originally built my rails app with the default Sqlite3 settings and I have attempted to switch it to Postgres. So maybe there's some conflicts with that going on as well. I want to be able to read my Heroku Logs in the future on my own and know exactly where to look. So if someone could provide a good tutorial about reading Heroku Logs that would be great as well.
Here's where I've looked so far:
I've looked on devcenter on heroku's website, but I'm not making the connection from their instructions, to the issue in my code. I'm just a that stuck point, but have been trying to figure it out for days! I'm worried that I'm just missing something basic, which is why I haven't been able to figure this out yet.
I've also looked at association_basics.html on ruby on rails guides because I've been having some syntax issues.
I've used foreman start to see if my Procfile is working and have gotten another huge list. I've also used heroku ps, which gives me web.1 crashed
Here's the Heroku Log that's also connected to my app's github page:
https://github.com/jsmit032/seasons-app/issues/29
If any other information is required, please let me know and I'll edit my questions so hopefully this can help others as well.
2014-11-21T19:27:58.271705+00:00 app[web.1]: has_many :user, through :user_to_destinations
doesn't look right - it should be
has_many :user, through: :user_to_destinations
at /app/app/models/destination.rb:3
So I got the whole app to deploy! Turns out it was a pre-complied issue.
So I went through the guide on Heroku for pre-compiling assets in Rails 4: https://devcenter.heroku.com/articles/rails-4-asset-pipeline
I also went through the heroku guide for prepping your rails 4 app:
https://devcenter.heroku.com/articles/getting-started-with-rails4#migrate-your-database
Also went through the heroku guide for SQLite on Heroku and the Deploying Rails Applications with Unicorn guide.
Looking through the console errors on the actual site was a huge help. It's how we figured out that the assets pipeline might not be working.
I've followed Ry Walker's instructions in Setting up a Wordpress blog on Heroku as a subdirectory of a Rails app also hosted on Heroku.
Everything seemed to work fine at first (I was able to access the Wordpress app through the /blog subdirectory), however after a few minutes I started getting a blank page as result of both /blog and [blog-app].herokuapp.com
I have gone through the steps twice and the same problem persists. Unfortunately, Heroku logs does not show any errors. I am afraid that this is related to the RewriteBase directive.
Has anyone faced similar problem?
I was having a similar problem, and it ended up being related to a bug in the rack-reverse-proxy gem where the content length header was getting corrupted.
There have been two people that have offered up fixes to the gem, but the fixes haven't been merged into the master branch. I forked the branch, copied the fix somebody had suggested, and used my version of the gem in the Gemfile. It's been working great ever since.
Here's the change you'll need to make in lib/rack/reverse-proxy.rb
# ensure content length header is correct
res.content_length = body.bytesize
I am having trouble with my site with precompiled assets looking nothing like my site with assets served on-the-go. So I figured, I should try things out in production.
Here's the problem, when I do, I get:
!! Invalid request
in my terminal log and in my browser I see
Error 107 (net::ERR_SSL_PROTOCOL_ERROR): SSL protocol error.
The graphic designer is not amused at the mess thats up right now, and I'd love to be able to reproduce the problem. Any ideas on how to get past this SSL issue?
The only way that I've ever been able to get sites implementing SSL working on my development box in production mode has been to set up Apache in front of my rails server (Webrick, or whatever). This is kind of a pain to set up, but it works. You should be able to find a guide on how to set it up using your exact configuration with a quick search. Another option would be to enable SSL via a configuration file, instead of by environment, so you could simply disable it regardless of your current environment. This is assuming everything else is actually correct and working...
I just upgraded to rails 3.2 Everything is working fine except error pages no longer show the normal development debug info. Instead it's showing the standard production error page (white background with red text in the middle:
"We're sorry, but something went wrong. We've been notified about this issue and we'll take a look at it shortly."
Is there a new setting or something I'm missing for rails 3.2? I've read over the upgrade instructions and do not see it mentioned anywhere. I tried downgrading to 3.1.3 and the error pages work again so this is definitely a rails 3.2 issue. Thanks.
Check the config.consider_all_requests_local inside development.rb. It must be set to true in order to show full error reports.
Nicolas, I'm faced the same problem and only saw the message We're sorry, but something went wrong. and nothing in logs.
The problem was in UTF-8 characters, so adding encoding declaration to the beginning of the file solved it:
# encoding = utf-8
If neither jibiels nor Dmitrys solution helped, try out the solution mentioned here:
Rails doesnt log tempalte errors in development mode
(Maybe this also helps you, #Nicolas)
When I run my app locally in test/dev my views come up nicely and everything is happy. When I try to navigate to those same erb files running on my remote server/local production server I get errors like the following:
ActionController::RoutingError (No route matches "/stylesheets/scaffold.css")
I've seen similar questions here on SO but none have been able to solve my problem. The closest thing I've found to an answer is the first answer here: Rails 404 error for Stylesheet or JavaScript files
As I understand it the best thing to do would be to configure my webserver to serve static files. How do I do this locally/on Heroku?
Update
As per raidfive's suggestion I changed config.serve_static_assets from false to true and this fixed my issue. However, I see that it says in production.rb that Apache or nginx should already be serving static assets. Is it any less good/professional to serve static assets in this way and if so how would I achieve the desired results if I'm using Heroku?
Update 2
Apparently Heroku does this automatically, I had an extra comma that was causing the mischief. I was able to look in the extended Heroku logs using the following tip to track down the trouble. Thanks SO!
Are you using Rails 3? By default Rails 3 / webrick does not serve static files in production mode. You can easily enable this by setting
config.serve_static_assets to true in your production.rb file.
In Rails5, you should comment
"config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?"
in config/enviroment/production.rb