Upload module can not upload file (Permission denied)

Yanxin Z. lists at ruby-forum.com
Tue Mar 29 01:43:58 MSD 2011


Hi Vitaly,
I change my files a little bit. Let me start from beginning.

The file I have:
conf/nginx.conf
  1 worker_processes 1;
  2
  3 error_log logs/error.log notice;
  4
  5 working_directory /opt/nginx;
  6
  7 events {
  8     worker_connections 1024;
  9 }
 10
 11 http {
 12     include mime.types;
 13     default_type application/octet-stream;
 14
 15     server {
 16         listen 80;
 17         client_max_body_size 100m;
 18
 19         # Upload form should be submitted to this location
 20         location /upload {
 21             # Pass altered request body to this location
 22             if ($request_method = POST) {
 23                 upload_pass @test;
 24                 break;
 25             }
 26
 27             # Store files to this directory
 28             # The directory is hashed, subdirectories 0 1 2 3 4 5 6 
7 8 9 should exist
 29             upload_store /tmp;
 30
 31             # Allow uploaded files to be read only by user
 32             upload_store_access user:rw group:rw all:rw;
 33
 34             # Set specified fields in request body
 35             upload_set_form_field "${upload_field_name}_name" 
$upload_file_name;
 36             upload_set_form_field 
"${upload_field_name}_content_type" $upload_content_type;
 37             upload_set_form_field "${upload_field_name}_path" 
$upload_tmp_path;
 38
 39             # Inform backend about hash and size of a file
 40             upload_aggregate_form_field "${upload_field_name}_md5" 
$upload_file_md5;
 41             upload_aggregate_form_field "${upload_field_name}_size" 
$upload_file_size;
 42
 43             upload_pass_form_field "^submit$|^description$";
 44             upload_cleanup 400 404 499 500-505;
 45         }
 46
 47         # Pass altered request body to a backend
 48         location @test {
 49             proxy_pass http://localhost:8080;
 50         }
 51    }
 52 }

/html/nginx.conf.default

 1
  2 #user  nobody;
  3 worker_processes  1;
  4
  5 #error_log  logs/error.log;
  6 #error_log  logs/error.log  notice;
  7 #error_log  logs/error.log  info;
  8
  9 #pid        logs/nginx.pid;
 10
 11
 12 events {
 13     worker_connections  1024;
 14 }
 15
 16
 17 http {
 18     include       mime.types;
 19     default_type  application/octet-stream;
 20
 21     #log_format  main  '$remote_addr - $remote_user [$time_local] 
"$request" '
 22     #                  '$status $body_bytes_sent "$http_referer" '
 23     #                  '"$http_user_agent" "$http_x_forwarded_for"';
 24
 25     #access_log  logs/access.log  main;
 26
 27     sendfile        on;
 28     #tcp_nopush     on;
 29
 30     #keepalive_timeout  0;
 31     keepalive_timeout  65;
 32
 33     #gzip  on;
 34
 35     server {
 36         listen       8080;
 37         server_name  localhost;
 38
 39         #charset koi8-r;
 40
 41         #access_log  logs/host.access.log  main;
 42
 43         location / {
 44             root   html;
 45             index  index.html index.htm;
 46         }
 47    }
 48 }


/html/upload.html

  1 <html>
  2 <head>
  3 <title>Test upload</title>
  4 </head>
  5 <body>
  6 <h2>Select files to upload</h2>
  7 <form name="upload" method="POST" enctype="multipart/form-data" 
action="/upload">
  8 <input type="file" name="file1"><br>
  9 <input type="file" name="file2"><br>
 10 <input type="file" name="file3"><br>
 11 <input type="file" name="file4"><br>
 12 <input type="file" name="file5"><br>
 13 <input type="file" name="file6"><br>
 14 <input type="submit" name="submit" value="Upload">
 15 <input type="hidden" name="test" value="value">
 16 </form>
 17 </body>
 18 </html>
 19


Then:
I run nginx on 8080 and 80 port
$/opt/nginx/sbin/nginx -c conf/nginx.conf.default
$/opt/nginx/sbin/nginx

I got in the web browser:
http://127.0.0.1/upload.html

I see the form, select the file, and "upload"

Then I see "404 Not Found".

The error.log shows:

2011/03/28 14:40:15 [error] 19402#0: *2 open() "/opt/nginx/html/upload" 
failed (2: No such file or directory), client: 127.0.0.1, server: 
localhost, request: "POST /upload HTTP/1.0", host: "localhost:8080", 
referrer: "http://127.0.0.1/upload.html"


I really do not know what should I do? It seems to me I missed the file 
upload. But I have no clue how to fix it.

Hopefully my explanation is clear to you.
Thank you very much.
Yanxin

-- 
Posted via http://www.ruby-forum.com/.



More information about the nginx mailing list