Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer 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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.