ruby-on-railsnginxamazon-s3dragonfly-gem

Rails + Dragonfly + Nginx - wrong root path for images


I have Rails app that uses

 gem 'dragonfly-s3_data_store', '~> 1.0.0'

and uploads assets to S3.

Files upload just fine, but then they won't display. If I look at the logs I see this:

 *150 open() "/etc/nginx/html/system/images/W1siZiIsIjIwMTUvMDUvMjEvMTgvNDIvNTUvOTEwL3ByZXNzX3Nob3J0LnBuZyJdXQ/press_short.png" failed (2: No such file or directory), client: 173.225.73.29, server: SERVERNAME, request: "GET /system/images/W1siZiIsIjIwMTUvMDUvMjEvMTgvNDIvNTUvOTEwL3ByZXNzX3Nob3J0LnBuZyJdXQ/press_short.png?sha=b4bb5663e1358837 HTTP/1.1", host: "EC2-ADDDRESS", referrer: "http://ec2-XXXX.compute-1.amazonaws.com/"

Solution

  • So for those who may experience similar issues. It is all tied to "verify_urls" in Dragonfly.

    You can find more answers in this thread:

    https://github.com/refinery/refinerycms/issues/2681

    Basically you need to either add secret to Dragonfly or turn verify_urls off (not recommended because of vulnerability).