Nginx 업로드 PUT 및 POST

Nginx 업로드 PUT 및 POST

nginx가 파일을 업로드하기 위해 POST 및 PUT 메서드를 허용하도록 노력하고 있습니다. nginx_upload_module-2.2.0을 컴파일했습니다.

방법을 찾을 수 없습니다. 나는 이것을 위해 역방향 프록시, 다른 백엔드 및 PHP를 사용하지 않고 nginx만 사용하고 싶습니다.

이것이 가능합니까?

이것은 내 conf입니다:

nginx version: nginx/1.2.3TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-cc-opt='-O2 -g' --add-module=/usr/src/nginx-1.2.3/nginx_upload_module-2.2.0


server {
    listen       80;
    server_name  example.com;

    location / {
        root   /html;
        autoindex on;
    }

    location /upload {
        root    /html;
        autoindex on;
        upload_store /html/upload 1;

        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_aggregate_form_field "$upload_field_name.md5" "$upload_file_md5";
        upload_aggregate_form_field "$upload_field_name.size" "$upload_file_size";
        upload_pass_form_field "^submit$|^description$";
        upload_cleanup 400 404 499 500-505;
    }
}

그리고 업로드 양식으로 이 페이지 끝에 나열된 것을 사용하려고 합니다.http://grid.net.ru/nginx/upload.en.html

답변1

POST 요청과 관련하여: 업로드 대상 디렉토리에 0 1 2 3 4 5 6 7 8 9 디렉토리를 만들지 않았습니까?

PUT 요청에는 언제든지 DAV를 사용할 수 있으며 이미 nginx에 컴파일되어 있습니다.

location /upload {
  alias     upload/data;
  client_body_temp_path  upload/client_tmp;

  dav_methods  PUT DELETE MKCOL COPY MOVE;

  create_full_put_path   on;
  dav_access             group:rw  all:r;

}

그리고 다음이 필요합니다(http 또는 위치에서):

client_max_body_size 10000m;

이제 시도해 보세요:

curl -T ubuntu-10.04.4-alternate-amd64.iso http://localhost/upload/blah2

건배! 게오르그

답변2

타사 업로드 모듈은 PUT을 전혀 지원하지 않습니다. PUT 업로드를 사용하려면 표준 nginx 업로드 처리를 사용해야 합니다.

관련 정보