首页 > 服务器 > debian下为Nginx添加webdav

作者:ghostry 发布时间:2018-11-18 浏览: 7430

转载注明出处: https://blog.ghostry.cn/server/889.html

debian下面apt安装的Nginx,已经有了webdav的支持。

使用nginx -V可以查看,

nginx version: nginx/1.6.2 TLS SNI support enabled configure
arguments: --with-cc-opt='-g -O2 -fstack-protector-strong -Wformat
-Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt=-Wl,-z,relro --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_spdy_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module --add-module=/home/lamby/temp/cdt.20181108182310.WIpV4lonx8.ags.nginx/nginx-1.6.2/debian/modules/nginx-auth-pam --add-module=/home/lamby/temp/cdt.20181108182310.WIpV4lonx8.ags.nginx/nginx-1.6.2/debian/modules/nginx-dav-ext-module --add-module=/home/lamby/temp/cdt.20181108182310.WIpV4lonx8.ags.nginx/nginx-1.6.2/debian/modules/nginx-echo --add-module=/home/lamby/temp/cdt.20181108182310.WIpV4lonx8.ags.nginx/nginx-1.6.2/debian/modules/nginx-upstream-fair --add-module=/home/lamby/temp/cdt.20181108182310.WIpV4lonx8.ags.nginx/nginx-1.6.2/debian/modules/ngx_http_substitutions_filter_module

其中--with-http_dav_module--add-module=/.../nginx-dav-ext-module就是表示支持webdav,
这样的情况下,只需添加配置文件即可。
比如

server {
    listen       81;
    server_name  webdav;
    error_log /var/log/nginx/webdav.error.log error;
    access_log  /var/log/nginx/webdav.access.log combined;
    location / {
        root /share;
        charset utf-8;
        autoindex on;
        dav_methods PUT DELETE MKCOL COPY MOVE;
        dav_ext_methods PROPFIND OPTIONS;
        create_full_put_path  on;
        dav_access user:rw group:r all:r;
        auth_basic "Authorized Users Only";
        auth_basic_user_file /etc/nginx/.htpasswd;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

其中/etc/nginx/.htpasswd是账号密码文件,使用htpasswd -c /etc/nginx/.htpasswd 用户名创建一个新的账号密码文件。htpasswd命令使用apt-get install apache2-utils安装。
写好文件后systemctl restart nginx.service即可

标签: nginx debian webdav

上一篇: 修改家里网络拓扑
下一篇: 一年的流量

添加新评论 »

*
*

欢迎评论!歡迎評論!Comments welcome!komentoj bonvenaj!댓글 오신 것을 환영합니다!
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: :cold: :cryy: :cute: :shy: :sleep: :struggle: :tea: :yahou: