1

I am attempting to get the nginx upload module working with my application. I have modified the server block in the nginx.conf file and doing so throws a 403 Forbidden error when I attempt to access my website. The logs say that the rails public directory cannot be accessed.

http {
passenger_root /opt/passenger-3.0.0;
passenger_ruby /usr/bin/ruby1.8;

include       mime.types;
default_type  application/octet-stream;


sendfile        on;
#tcp_nopush     on;
client_max_body_size 30M; #allow large uploads
#keepalive_timeout  0;


#gzip  on;

server {
    listen       80;
    server_name  url.com;
    root /path/current/public;


 # Match this location for the upload module
 location /images/fast_upload {
 # pass request body to here
 upload_pass @fast_upload_endpoint;


 upload_store /path/shared/uploads_tmp 1;

 # set permissions on the uploaded files
  upload_store_access user:rw group:rw all:r;

 # Set specified fields in request body
 # this puts the original filename, new path+filename and content type in the$
 upload_set_form_field upload[fast_asset][original_name] "$upload_file_name";
 upload_set_form_field upload[fast_asset][content_type] "$upload_content_type$
 upload_set_form_field upload[fast_asset][filepath] "$upload_tmp_path";

 upload_pass_form_field "^image_id$|^authenticity_token$|^format$";
 upload_cleanup 400 404 499 500-505;
 }

 location @fast_upload_endpoint {


  passenger_enabled on;
  rails_env production;
 }


    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

  }
 }

When I move "passenger_enabled on" out of the location block it works fine. However it doesn't look like nginx takes the file uploads with that configuration in the .conf file.

1 Answer 1

1
location @fast_upload_endpoint {

     passenger_enabled on;
     rails_env production;
  }
location / {
 rails_env production;
 passenger_enabled on;
}

I added a second location block and it seems ok now.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .