Simple way to setup webdav by docker

Prepare:

# set up docker after turn on device
sudo systemctl enable docker

# get docker image
docker pull bytemark/webdav

# open port
sudo firewall-cmd --zone=public --add-port=9789/tcp --permanent
sudo firewall-cmd --reload

# create data folder and webdav home path
mkdir -p /root/webdav/data

write docker-compose.yml

version: '1'
services:
  webdav:
    container_name: webdav
    image: bytemark/webdav
    restart: always
    ports:
      - "9789:80"
    environment:
      AUTH_TYPE: Digest
      USERNAME: your-name
      PASSWORD: your-passwd
      LOCATION: /webdav
    volumes:
      - /root/webdav/data:/var/lib/dav/data

setup Container

docker-compose -f docker-compose.yml up &

We can access it by http://weiy.cc:9789/webdav/

Use https for webdav

Go to /root/webdav.
create folder ssl under /root/webdav.
cp exist certificate files fullchain.pem and privkey.pem to /root/webdav/ssl

write docker-compose.yml:

version: '1'
services:
  webdav:
    container_name: webdav
    image: bytemark/webdav
    restart: always
    ports:
      - "9789:80"
    environment:
      AUTH_TYPE: Digest
      USERNAME: your-name
      PASSWORD: your-passwd
    volumes:
      - /root/webdav/data:/var/lib/dav/data

  nginx:
    image: nginx:latest
    container_name: nginx
    restart: always
    ports:
      - "9880:80"
      - "9443:443"
    volumes:
      - ./nginx.conf:/etc/nginx/conf.d/default.conf
      - ./ssl:/etc/nginx/ssl

write nginx.conf

    server {
        listen 80;
        server_name weiy.cc;
        # 强制 HTTP 跳转 HTTPS
        return 301 https://$host$request_uri;
    }

    server {
        listen 443 ssl;
        server_name weiy.cc;

        ssl_certificate  /etc/nginx/ssl/fullchain.pem;
        ssl_certificate_key /etc/nginx/ssl/privkey.pem;

        ssl_protocols TLSv1.2 TLSv1.3;
        ssl_ciphers HIGH:!aNULL:!MD5;

        location / {
            proxy_pass http://webdav:80;
        }
    }

Make it works:

docker-compose -f docker-compose.yml up &

We can access it at: https://weiy.cc:9443/

see files on webdav by browser:

If you want to use Joplin with webdav, just change AUTH_TYPE to Basic in docker-compose.yml

Input webdav information for Joplin to sync data.

Categories: Tool

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Tex To PDF
: convert the Latex file which suffix is tex to a PDF file

X
0
Would love your thoughts, please comment.x
()
x