nginx-upload_module-POST上出现404错误

时间:2019-04-05 21:39:52

标签: nginx

尝试从另一个应用程序将文件上传到nginx。在access.log中有404个错误。 error.logNo such file or directory错误。应该如何从POST请求创建文件?这是由于配置引起的问题吗?

25.52.21.2 - - [05/Apr/2019:21:05:08 +0000] "POST /upload/_upload/stream_TS-49410_1_audio_2_2.ts HTTP/1.1" 404 169 "-" 
25.52.21.2 - - [05/Apr/2019:21:05:08 +0000] "POST /upload/_upload/stream_TS-49410_1_audio_1_2.ts HTTP/1.1" 404 169 "-" 
25.52.21.2 - - [05/Apr/2019:21:05:08 +0000] "POST /upload/_upload/stream_TS-49410_1_video_1.ts HTTP/1.1" 404 169 "-" 
25.52.21.2 - - [05/Apr/2019:21:05:09 +0000] "POST /upload/_upload/stream_TS-49410_1_audio_2_2.ts HTTP/1.1" 404 169 “-“
25.52.21.2 - - [05/Apr/2019:21:05:09 +0000] "POST /upload/_upload/stream_TS-49410_1_audio_1_2.ts HTTP/1.1" 404 169 "-" 
25.52.21.2 - - [05/Apr/2019:21:05:09 +0000] "POST /upload/_upload/stream_TS-49410_1_video_1.ts HTTP/1.1" 404 169 "-" 
25.52.21.2 - - [05/Apr/2019:21:05:10 +0000] "POST /upload/_upload/stream_TS-49410_1_audio_2_2.ts HTTP/1.1" 404 169 "-" 
25.52.21.2 - - [05/Apr/2019:21:05:10 +0000] "POST /upload/_upload/stream_TS-49410_1_audio_1_2.ts HTTP/1.1" 404 169 "-" 
25.52.21.2 - - [05/Apr/2019:21:05:10 +0000] "POST /upload/_upload/stream_TS-49410_1_video_1.ts HTTP/1.1" 404 169 "-" 
25.52.21.2 - - [05/Apr/2019:21:05:11 +0000] "POST /upload/_upload/stream_TS-49410_1_audio_2_2.ts HTTP/1.1" 404 169 "-" 
25.52.21.2 - - [05/Apr/2019:21:05:11 +0000] "POST /upload/_upload/stream_TS-49410_1_audio_1_2.ts HTTP/1.1" 404 169 "-" 

2019/04/05 21:05:12 [error] 2845#0: *3258 open() "/usr/local/nginx/html/upload/_upload/stream_TS-49410_1_audio_2_2.ts" failed (2: No such file or directory), client: 25.52.21.2, server: localhost, request: "POST /upload/_upload/stream_TS-49410_1_audio_2_2.ts HTTP/1.1", host: "25.52.21.101"
2019/04/05 21:05:12 [error] 2845#0: *3259 open() "/usr/local/nginx/html/upload/_upload/stream_TS-49410_1_audio_1_2.ts" failed (2: No such file or directory), client: 25.52.21.2, server: localhost, request: "POST /upload/_upload/stream_TS-49410_1_audio_1_2.ts HTTP/1.1", host: "25.52.21.101"
2019/04/05 21:05:13 [error] 2845#0: *3260 open() "/usr/local/nginx/html/upload/_upload/stream_TS-49410_1_video_1.ts" failed (2: No such file or directory), client: 25.52.21.2, server: localhost, request: "POST /upload/_upload/stream_TS-49410_1_video_1.ts HTTP/1.1", host: "25.52.21.101"
2019/04/05 21:05:13 [error] 2845#0: *3261 open() "/usr/local/nginx/html/upload/_upload/stream_TS-49410_1_video_2.ts" failed (2: No such file or directory), client: 25.52.21.2, server: localhost, request: "POST /upload/_upload/stream_TS-49410_1_video_2.ts HTTP/1.1", host: "25.52.21.101"
2019/04/05 21:05:13 [error] 2845#0: *3262 open() "/usr/local/nginx/html/upload/_upload/stream_TS-49410_1_audio_2_2.ts" failed (2: No such file or directory), client: 25.52.21.2, server: localhost, request: "POST /upload/_upload/stream_TS-49410_1_audio_2_2.ts HTTP/1.1", host: "25.52.21.101"
2019/04/05 21:05:13 [error] 2845#0: *3263 open() "/usr/local/nginx/html/upload/_upload/stream_TS-49410_1_audio_1_2.ts" failed (2: No such file or directory), client: 25.52.21.2, server: localhost, request: "POST /upload/_upload/stream_TS-49410_1_audio_1_2.ts HTTP/1.1", host: "25.52.21.101"
2019/04/05 21:05:14 [error] 2845#0: *3264 open() "/usr/local/nginx/html/upload/_upload/stream_TS-49410_1_video_2.ts" failed (2: No such file or directory), client: 25.52.21.2, server: localhost, request: "POST /upload/_upload/stream_TS-49410_1_video_2.ts HTTP/1.1", host: "25.52.21.101"
2019/04/05 21:05:14 [error] 2845#0: *3265 open() "/usr/local/nginx/html/upload/_upload/stream_TS-49410_1_audio_2_2.ts" failed (2: No such file or directory), client: 25.52.21.2, server: localhost, request: "POST /upload/_upload/stream_TS-49410_1_audio_2_2.ts HTTP/1.1", host: "25.52.21.101"
2019/04/05 21:05:14 [error] 2845#0: *3266 open() "/usr/local/nginx/html/upload/_upload/stream_TS-49410_1_audio_1_2.ts" failed (2: No such file or directory), client: 25.52.21.2, server: localhost, request: "POST /upload/_upload/stream_TS-49410_1_audio_1_2.ts HTTP/1.1", host: "25.52.21.101"
2019/04/05 21:05:15 [error] 2845#0: *3267 open() "/usr/local/nginx/html/upload/_upload/stream_TS-49410_1_video_2.ts" failed (2: No such file or directory), client: 25.52.21.2, server: localhost, request: "POST /upload/_upload/stream_TS-49410_1_video_2.ts HTTP/1.1", host: "25.52.21.101"

nginx.conf

# user nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


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

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    gzip  on;

    server {
        listen       80;
        server_name  localhost;
        client_max_body_size 0;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            autoindex on;
        }

        location = /upload {
            upload_resumable on;

            # For CORS
            if ($request_method = OPTIONS) {
                add_header Pragma no-cache;
                add_header X-Content-Type-Options nosniff;

                # Access control for CORS
                add_header Access-Control-Allow-Origin "*";
                add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS";
                add_header Access-Control-Allow-Headers "cache-control, content-range, accept, origin, session-id, content-disposition, x-requested-with, content-type, content-description, referer, user-agent";
                add_header Access-Control-Allow-Credentials "true";

                # 10 minute pre-flight approval
                add_header Access-Control-Max-Age 600;

                return 204;
            }

            if ($request_method = POST) {
                add_header Pragma no-cache;
                add_header X-Content-Type-Options nosniff;
                #add_header Cache-control "no-story, no-cache, must-revalidate";

                # Access control for CORS
                add_header Access-Control-Allow-Origin "*";
                add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS";
                add_header Access-Control-Allow-Headers "cache-control, content-range, accept, origin, session-id, content-disposition, x-requested-with, content-type, content-description, referer, user-agent";
                add_header Access-Control-Allow-Credentials "true";

                # 10 minute pre-flight approval
                add_header Access-Control-Max-Age 600;

                # Headers specifically for the upload module
                upload_add_header Access-Control-Allow-Origin "*";
                upload_add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS";
                upload_add_header Access-Control-Allow-Credentials "true";
                upload_add_header Access-Control-Allow-Headers "cache-control, content-range, accept, origin, session-id, content-disposition, x-requested-with, content-type, content-description, referer, user-agent";

                # Set specified fields in request body
                # This puts the original filename, new path+filename and content type
                # in the requests params
                upload_set_form_field $upload_field_name.name "$upload_file_name";
                upload_set_form_field $upload_field_name.content_type "$upload_content_type";
                upload_set_form_field $upload_field_name.path "$upload_tmp_path";

                upload_cleanup 400 404 499 500-505;
            }

            # After upload, pass altered request body to this view
            upload_pass @complete;

            # Store files to this directory

            upload_store /usr/local/nginx/html/upload/_upload;

            # set permissions on the uploaded files
            upload_store_access all:rw;
        }

        location @complete {
            proxy_pass http://localhost:8000;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration

    server {
        listen       8000;
        listen       localhost:8000;
        server_name  localhost  alias  another.alias;

        location / {
            root   html;
            index  index.html index.htm;
        }
    }


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

0 个答案:

没有答案