NGINX 設定 WebDAV (HTTPS + Authentication)

為了能夠自由的同步 Zotero 中的論文,我們可以透過 WebDAV 來同步電腦中的論文到雲端上。以下分為四個步驟介紹如何在 Ubuntu 使用 NGINX 設定帶有 HTTPS、Auth 的 WebDAV 功能。

A. 安裝與設定 NGINX

  • 安裝 nginx-full (dep: libnginx-mod-http-dav-ext)
    • $ apt install nginx-full
  • 加入 WebDAV 設定檔
    • $ sudo nano /etc/nginx/sites-available/webdav.conf
    • $ cd /etc/nginx/sites-enabled
    • $ ln -s ../sites-available/webdav.conf .
  • webdav.conf 內容
  • 如果你要使用 domain name,請在 listen 前面補上 server_name
    • server_name your-webdav-domain.com;

B. 測試 NGINX WebDAV (w/o HTTPS/Authentication)

  • 確認設定檔正確
    • $ nginx -t
  • 重啟 NGINX
    • $ systemctl restart nginx
  • 透過 cadaver 測試 WebDAV 是否有啟動成功
    • $ apt install cadaver
    • $ cadaver http://your-webdav-domain.com

C. 設定 NGINX Authentication

Reference: Restricting Access with HTTP Basic Authentication

  • 產生 Basic Authentication 檔案 (把 user1 改成你想要的帳號名稱)
    • $ htpasswd -c /etc/nginx/.htpasswd user1
  • 確認檔案產生成功
    • $ cat /etc/nginx/.htpasswd
  • 在 webdav.conf 中啟動 HTTP Basic Authentication
  • 重啟 NGINX
    • $ systemctl restart nginx
  • 透過 cadaver 測試 WebDAV 是否有啟動成功
    • $ cadaver http://your-webdav-domain.com

D. 設定 WebDAV HTTPS

  • 安裝 certbot
    • $ apt install certbot
  • 設定 certbot
    • $ certbot --nginx your-webdav-domain.com
  • 透過 cadaver 測試 WebDAV 是否有啟動成功 (https://your-webdav-domain.com)



如果你覺得這篇文章不錯,歡迎打賞

BTH: 35QooNA82isrmQLmpEnqXpJoxeZmaPubPf

ETH:0x4cf61fea5EA842D202B85158d8b5e239C872De46

或是點選下方圖片贊助我一杯咖啡:

Leave a reply:

Your email address will not be published.

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料