Nginx, Passenger, Rails - File Uploads Do Not Work

I am not able to get file uploads working under Nginx with PassengerL. I am using Carrierwave as the uploader, but that shouldn’t make a difference.

The error on the production.log:

F, [2014-10-31T14:05:41.938864 #16078] FATAL -- : 
Errno::ENOENT (No such file or directory - identify):
  app/controllers/adults_controller.rb:44:in `update'

There are no errors in /var/log/nginx/errors.log

Her is my server Nginx site config:

server {
    listen 80;
    root /home/deploy/mysite/current/public;
    passenger_enabled on;
    passenger_ruby /home/deploy/.rvm/gems/ruby-2.1.4/wrappers/ruby;
    passenger_user deploy;

server {
    listen 443 ssl;
    root /home/deploy/mysite/current/public;
    passenger_enabled on;
    passenger_ruby /home/deploy/.rvm/gems/ruby-2.1.4/wrappers/ruby;
    passenger_user deploy;

    ssl on;
    ssl_certificate      /etc/nginx/ssl/www_mysite_in.crt;
    ssl_certificate_key  /etc/nginx/ssl/myserver.key;

    ssl_protocols        TLSv1 TLSv1.1 TLSv1.2;

    #Disables all weak ciphers
    ssl_ciphers 'AES256+EECDH:AES256+EDH';

    # Specifies that server ciphers should be preferred over client (e.g. browser) ciphers when using SSL/TLS.
    ssl_prefer_server_ciphers on;

    ssl_session_cache shared:SSL:10m;

    ssl_stapling on;
    ssl_stapling_verify on;
    resolver valid=300s;
    resolver_timeout 10s;

    passenger_set_cgi_param HTTP_X_FORWARDED_PROTO https;

I can verify that the upload is received and saved into /tmp

-rw-------  1 deploy deploy  7093 Oct 31 17:21 RackMultipart20141031-11691-14busua
-rw-------  1 deploy deploy  7093 Oct 31 17:21 mini_magick20141031-11691-w6gmhc.gif

And I double-checked the permission on /tmp

drwxrwxrwt   4 root root       4096 Oct 31 17:21 tmp

So, all that looks good. So there must be something in the handoff between Nginx and rails app, that the rails app can not read the file. My app is running as the ‘deploy’ user.

Any ideas would be appreciated.

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

The error is referencing ImageMagick’s identify command. Either imagemagick is not installed, or the path to the command is not specified in your CarrierWave initializer.

I gave up. Blew away the image and installed a new one. All is well.