文書更新:2019年06月18日(火) 午前11時17分34秒

Home > 備忘録(Fedora) > nginx > nginx-dav-ext-module を利用してみる( 137 )

nginx で WebDAV(Basic認証) を使うために nginx-dav-ext-module をインストールする

nginx-dav-ext-module を利用してみる

  1. nginx-dav-ext-module をダウンロードし、解凍をする
  2. [root@server]# wget https://codeload.github.com/arut/nginx-dav-ext-module/zip/master
    
    [root@server]# unzip ./master
  3. nginx ソース(src.rpm)のダウンロード
  4. [root@server]# dnf download --source nginx
    /home/ユーザー名 のディレクトリーにダウンロードされています
  5. nginx ソース(src.rpm)のインストール
  6. [root@server]# rpm -ivh ./nginx-x.xx.x-x.fcxx.src.rpm
    
    ※結果表示
    [root@server]# ls /root/rpmbuild/
    SOURCES  SPECS
  7. spec file の編集
  8. 「--add-module=/home/ユーザー名/nginx-dav-ext-module-master \」を挿入する
    [root@server]# vi /root/rpmbuild/SPECS/nginx.spec
    ~~~~~前半省略~~~~~
    # So the perl module finds its symbols:
    nginx_ldopts="$RPM_LD_FLAGS -Wl,-E"
    if ! ./configure \
        --prefix=%{_datadir}/nginx \
        --sbin-path=%{_sbindir}/nginx \
        --modules-path=%{_libdir}/nginx/modules \
        --conf-path=%{_sysconfdir}/nginx/nginx.conf \
        --error-log-path=%{_localstatedir}/log/nginx/error.log \
        --http-log-path=%{_localstatedir}/log/nginx/access.log \
        --http-client-body-temp-path=%{_localstatedir}/lib/nginx/tmp/client_body \
        --http-proxy-temp-path=%{_localstatedir}/lib/nginx/tmp/proxy \
        --http-fastcgi-temp-path=%{_localstatedir}/lib/nginx/tmp/fastcgi \
        --http-uwsgi-temp-path=%{_localstatedir}/lib/nginx/tmp/uwsgi \
        --http-scgi-temp-path=%{_localstatedir}/lib/nginx/tmp/scgi \
        --pid-path=/run/nginx.pid \
        --lock-path=/run/lock/subsys/nginx \
        --user=%{nginx_user} \
        --group=%{nginx_user} \
    %if 0%{?with_aio}
        --with-file-aio \
    %endif
        --with-ipv6 \
        --with-http_ssl_module \
        --with-http_v2_module \
        --with-http_realip_module \
        --with-stream_ssl_preread_module \
        --with-http_addition_module \
        --with-http_xslt_module=dynamic \
        --with-http_image_filter_module=dynamic \
    %if %{with geoip}
        --with-http_geoip_module=dynamic \
    %endif
        --with-http_sub_module \
        --with-http_dav_module \
        --with-http_flv_module \
        --with-http_mp4_module \
        --with-http_gunzip_module \
        --with-http_gzip_static_module \
        --with-http_random_index_module \
        --with-http_secure_link_module \
        --with-http_degradation_module \
        --with-http_slice_module \
        --with-http_stub_status_module \
        --with-http_perl_module=dynamic \
        --with-http_auth_request_module \
        --with-mail=dynamic \
        --with-mail_ssl_module \
        --with-pcre \
        --with-pcre-jit \
        --with-stream=dynamic \
        --with-stream_ssl_module \
        --add-module=/home/ユーザー名/nginx-dav-ext-module-master \	←こちでを挿入する(\以降に空白があるとうまくいかない)
    %if 0%{?with_gperftools}
        --with-google_perftools_module \
    %endif
        --with-debug \
        --with-cc-opt="%{optflags} $(pcre-config --cflags)" \
        --with-ld-opt="$nginx_ldopts"; then
      : configure failed
      cat objs/autoconf.err
      exit 1
    fi
    
    make %{?_smp_mflags}
    	~~~~~後半省略~~~~~
  9. nginx のビルド
  10. [root@server]# rpmbuild -bb /root/rpmbuild/SPECS/nginx.spec
    実行中(%prep): /bin/sh -e /var/tmp/rpm-tmp.2Lfb4k
    + umask 022
    + cd /root/rpmbuild/BUILD
    + cd /root/rpmbuild/BUILD
    + rm -rf nginx-1.14.1
    
    	~~~~~途中省略~~~~~
    
    書き込み完了: /root/rpmbuild/RPMS/x86_64/nginx-mod-stream-debuginfo-1.14.1-2.fc29.x86_64.rpm
    実行中(%clean): /bin/sh -e /var/tmp/rpm-tmp.xZ7wKh
    + umask 022
    + cd /root/rpmbuild/BUILD
    + cd nginx-1.14.1
    + /usr/bin/rm -rf /root/rpmbuild/BUILDROOT/nginx-1.14.1-2.fc29.x86_64
    + exit 0
    [root@server]#
  11. nginx のビルド結果
  12. [root@server]# ls /root/rpmbuild/RPMS/x86_64/
    nginx-1.14.1-2.fc29.x86_64.rpm		←こちらに出来上がっている
    nginx-debuginfo-1.14.1-2.fc29.x86_64.rpm
    nginx-debugsource-1.14.1-2.fc29.x86_64.rpm
    nginx-mod-http-image-filter-1.14.1-2.fc29.x86_64.rpm
    nginx-mod-http-image-filter-debuginfo-1.14.1-2.fc29.x86_64.rpm
    nginx-mod-http-perl-1.14.1-2.fc29.x86_64.rpm
    nginx-mod-http-perl-debuginfo-1.14.1-2.fc29.x86_64.rpm
    nginx-mod-http-xslt-filter-1.14.1-2.fc29.x86_64.rpm
    nginx-mod-http-xslt-filter-debuginfo-1.14.1-2.fc29.x86_64.rpm
    nginx-mod-mail-1.14.1-2.fc29.x86_64.rpm
    nginx-mod-mail-debuginfo-1.14.1-2.fc29.x86_64.rpm
    nginx-mod-stream-1.14.1-2.fc29.x86_64.rpm
    nginx-mod-stream-debuginfo-1.14.1-2.fc29.x86_64.rpm
  13. nginx のインストール
  14. [root@server]# rpm -ivh /root/rpmbuild/RPMS/x86_64/nginx-1.14.1-2.fc29.x86_64.rpm
  15. 後処理
  16. [root@server]# rm -rf /root/rpmbuild
    
    [root@server]# rm ./nginx-x.xx.x-x.fcxx.src.rpm

nginx.confに追加

[root@server]# vi /etc/nginx/nginx.conf
location /myWebdav {
		root /...../webdav;
		# Basic認証
		auth_basic "Private Property";
		auth_basic_user_file /...../.htpasswd;
		# アップロードサイズの上限
		client_max_body_size   100m;
		# 必要なディレクトリも作成する
		create_full_put_path on;
		# リクエストボディのサイズがこのバッファのサイズ( client_body_buffer_size )を越えた場合の保存先
		client_body_temp_path  /tmp;
		# WebDAV設定
		dav_methods PUT DELETE MKCOL COPY MOVE;
		dav_access group:rw all:r;
		dav_ext_methods PROPFIND OPTIONS;
	}