关于nginx:Nginx上传与下载文件

39次阅读

共计 952 个字符,预计需要花费 3 分钟才能阅读完成。

工作环境中不能随便往服务器上传文件,或者嫌用 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 测试:

正文完
 0