Nginx上传与下载文件

工作环境中不能随意往服务器上传文件,或者嫌用rz/sz命令太慢,可以试试用nginx。

编译nginx:

./configure --prefix=../nginx --with-http_dav_module
make -j 2
make install

参考配置:

#user nobody;
worker_processes auto;

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

pid logs/nginx.pid;

events {
    worker_connections 256;
}

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 8080;
        server_name uplsrv;

        #charset koi8-r;

        client_body_buffer_size 128k;
        client_max_body_size 1G;

        access_log logs/uplsrv.access.log main;

        location / {
            root /home/work/upl;
            autoindex on;
        }

        location ~ "/upl/([0-9A-Za-z.-_]*)$" {
            alias /home/work/upl/$1;
            dav_methods PUT DELETE;
            dav_access group:rw all:r;
            client_body_temp_path /tmp/upl;
            #create_full_put_path on;
        }
    }
}

使用Postman测试:
Nginx上传与下载文件_第1张图片

你可能感兴趣的:(nginx)