Why do some assets give 403 forbidden?

1.1k views Asked by At

I am using ROR, nginx, passenger...

If there is no picture in the DB then my app will serve the 'default_avatar.png'. I noticed I was unable to save new pictures. So, I updated my dragonfly initializer to point at my db server:

...
  # I have obscured the host IP for this example. 
  config.url_host = Rails.env.production? ? 'http://IP_OF_HOST' : 'http://localhost:3000'
...

Now I can save pictures and view them through my app, but the 'default_avatar.png' does not resolve. Oddly enough, other image assets do seem to come through. Why do I get 403? At first guess I thought it was a permissions error. But then why would it serve the other images?

UPDATE:

I have just noticed a very important clue. When the assets do not work, they have the url:

/media/jakbfAGasgAgADSGANJGFDgbnadglnalgbakljbgkjabg/default_avatar.png

And when they do work:

/assets/avatar.png

I should mention that I have 2 app servers and 1 db server. I do not believe it to be a permissions error.

1

There are 1 answers

0
NickGnd On

I've encountered the same problem.

You need to specify the extension of the file when using the html helper provided by AssetTagHelper lib.

This will work: <%= image_tag('avatar.png') %>

This won't work: <%= image_tag('avatar') %>

Not easy to debug.