LoginSignup
22

More than 5 years have passed since last update.

nginxでWebDAV (nginx-dav-ext-moduleはなし)

Last updated at Posted at 2015-01-13

自分メモ

概要

CentOS6で、nginx-dav-ext-moduleは入れない場合の、nginx WebDAV設定一例。
maven repository建てるのに使いました。

sudoとかは省略してます

やり方

いつも通り /etc/nginx/conf.d に.confファイルを作る。

webdav.conf
server {
  listen 6668;
  server_name example.server.com;

  location / {
    root /usr/share/nginx/html/webdav;

    # Basic認証
    auth_basic "webdav test server.";
    auth_basic_user_file /etc/nginx/conf.d/.htpasswd;

    # アップロードサイズの上限
    client_max_body_size   100m;

    ## ブラウザから確認したい場合
    autoindex on;
    autoindex_exact_size off;
    autoindex_localtime on;

    client_body_temp_path  /usr/share/nginx/html/webdav;
    create_full_put_path on;

    # WebDAV設定
    dav_access group:r all:r;
    dav_methods  PUT DELETE MKCOL COPY MOVE;
    #dav_ext_methods PROPFIND OPTIONS;

    # log.
    access_log /var/log/nginx/maven.access.log;
    error_log /var/log/nginx/maven.error.log;

    # IPを制限する場合
    # limit_except GET {
    #   allow xxx.xxx.xx.xx;
    #   deny all;
    # }
  }
}

Basic認証用のuserid/passwordを作る。

$ htpasswd -nbd username password > /etc/nginx/conf.d/.htpasswd

コマンドが無い時は http://koexuka.blogspot.jp/2013/06/apachehtpasswdbasic.html?m=1

ファイルの置き場を作る。

$ mkdir /usr/share/nginx/html/webdav
$ chown nginx:nginx /usr/share/nginx/html/webdav
$ echo "dummy." > /usr/share/nginx/html/webdav/dummy.txt

nginxをrestart.

$ service nginx restart

6668ポートを開ける. /etc/sysconfig/iptables に以下を追記.

-A INPUT -p tcp -m tcp --dport 6668 -j ACCEPT

iptablesをrestart.

$ service iptables restart

アクセスしてみる

ブラウザから, http://your.server.address:6668

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
22