Add WebDAV support for Nginx under Linux

Source: Internet
Author: User
Tags openssl sftp access git clone


Add WebDAV support for Nginx

In compiling nginx know there is a "–with-http_dav_module" of such a parameter, but really let me have to actually be used for this feature, say something surprisingly – solve the problem of cotton using Android phone through SFTP access to Mac OS x video resources.
WebDAV (web-based Distributed Authoring and Versioning) a communication protocol based on the HTTP 1.1 protocol. It extends HTTP 1.1, adding new methods beyond several HTTP standard methods such as GET, POST, head, so that applications can read directly to Web servers and support write-file locking (locking) and unlocking (Unlock). You can also support version control of files. (Learn more)
Support for WebDAV protocols can be enabled by adding "–with-http_dav_module" at compile time, but to enable complete functionality and support for client operations, another module is introduced: Ngx-dav-ext-module. With regard to the description of this issue, the official document of Nginx has some light strokes to write: "WebDAV clients that require additional WebDAV methods to operate won't work with this modul E. "
The following is the configuration process
Download Ngx-dav-ext-module:


Cd/usr/local/src && git clone--recursive ps://github.com/arut/nginx-dav-ext-module ">https://github.com/ Arut/nginx-dav-ext-module

Recompile nginx:


./configure \
--prefix=/opt/webserver/nginx \
--without-http_memcached_module \
--USER=WWW \
--GROUP=WWW \
--with-http_image_filter_module \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_gzip_static_module \
--WITH-OPENSSL=/USR/LOCAL/SRC/OPENSSL-1.0.1J \
--with-zlib=/usr/local/src/zlib-1.2.8 \
--with-pcre=/usr/local/src/pcre-8.36 \
--with-http_sub_module \
--add-module=/usr/local/src/nginx-accesskey-2.0.3 \
--add-module=/usr/local/src/ngx_http_geoip2_module \
--with-http_realip_module \
--with-http_mp4_module \
--with-http_dav_module \
--add-module=/usr/local/src/nginx-dav-ext-module

Compilation and Backup:


#备份原nginx程序文件
Mv/opt/webserver/nginx/sbin/nginx/opt/webserver/nginx/sbin/nginx.bak &&
\CP Objs/nginx/opt/webserver/nginx/sbin/nginx &&
Nginx-t

Modify the nginx.conf, roughly as follows:


server {
Listen 8080;
server_name site.com;
Client_max_body_size 20M;
Location/{
Dav_methods put DELETE mkcol COPY move;
Dav_ext_methods PROPFIND OPTIONS;
Dav_access GROUP:RW all:r;
root/var/www/dav/;
Auth_basic "Restricted";
AUTH_BASIC_USER_FILE/VAR/WWW/DAV/.HTPASSWD;
}
}

About authentication encryption, can be generated here, the generated username password by line to write the specified password file, such as the above/var/www/dav/.htpasswd file.


Update Nginx:


#测试配置文件没有问题
Nginx-t
#升级
Make upgrade
Client Testing


(1) Mac recommended use of Tramsmit:

can upload and download the modified file:


(2) If WebDAV does not use the HTTPS protocol, WINDOWS7, WINDOWS8 cannot be mounted by mapping a network drive. The workaround is as follows:
1, modify the registry: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\WebClient\Parameters, change the Basicauthlevel value to 2, That is, HTTP and HTTPS are supported at the same time, only HTTPS is supported by default,
2, and then restart the service:

net stop WebClient
net start WebClient

3, Map Network Drive can

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.