Suse linux 11 SP2 nginx 使用笔记

 

1. 下载源代码
 
2. DAV模块缺省没有编译,要加入编译选项
# ./configure --with-http_dav_module
 
# make install
 
# cd /usr/local/nginx/sbin
 
# ./nginx
 
# ps -ef | grep nginx
 
# ps -ef | grep nginx
root      7330     1  0 22:46 ?        00:00:00 nginx: master process ./nginx
nobody    7331  7330  0 22:46 ?        00:00:00 nginx: worker process
 
# ./nginx -h
nginx version: nginx/1.4.2
Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]

Options:
  -?,-h         : this help
  -v            : show version and exit
  -V            : show version and configure options then exit
  -t            : test configuration and exit
  -q            : suppress non-error messages during configuration testing
  -s signal     : send signal to a master process: stop, quit, reopen, reload
  -p prefix     : set prefix path (default: /usr/local/nginx/)
  -c filename   : set configuration file (default: conf/nginx.conf)
  -g directives : set global directives out of configuration file
 
 
2. WebDav设置
nginx的缺省html目录/usr/local/nginx/html, 为了以后的WebDav测试,先简单将权限设置为777
# chmod 777 /usr/local/nginx/html
 
nignx 源代码不包含digest认证模块
 
下载digest模块并解压到目录nginx-http-auth-digest-master
 
# ./configure --with-http_dav_module  --add-module=nginx-http-auth-digest-master
 
nginx WebDav的配置: (http://wiki.nginx.org/HttpDavModule)
修改/usr/local/nginx/conf/nginx.conf
 
location / {
            root   html;
            index  index.html index.htm;
            dav_methods  PUT DELETE MKCOL COPY MOVE;

            create_full_put_path   on;
            dav_access                all:rw;
        }
 
用curl测试上传:curl -T test.txt http://127.0.0.1/test.txt
 
 
nginx digest认证的配置:
 
创建密码文件:
# htdigest2 -c /usr/local/nginx/conf/webdav.passwd WebDAV-Realm steve
Adding password for steve in realm WebDAV-Realm.
New password:
Re-type new password: 
 
修改/usr/local/nginx/conf/nginx.conf
auth_digest_user_file /usr/local/nginx/conf/webdav.passwd;
        auth_digest_shm_size 4m;   # the storage space allocated for tracking active sessions

        location / {
            root   html;
            index  index.html index.htm;
            dav_methods  PUT DELETE MKCOL COPY MOVE;

            create_full_put_path   on;
            dav_access             all:rw;

            auth_digest 'WebDAV-Realm'; # realm name
            auth_digest_timeout 60s; # allow users to wait 1 minute between receiving the
                                     # challenge and hitting send in the browser dialog box
            auth_digest_expires 10s; # after a successful challenge/response, let the client
                                     # continue to use the same nonce for additional requests
                                     # for 10 seconds before generating a new challenge
             auth_digest_replays 20; # also generate a new challenge if the client uses the
                                     # same nonce more than 20 times before the expire time limit
        }
 
再用curl上传(没有用户名和密码)会失败
# curl -T test.txt http://127.0.0.1/test.txt
posted @ 2014-05-14 09:54  huidaoli  阅读(836)  评论(0编辑  收藏  举报