惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Palo Alto Networks Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
CERT Recently Published Vulnerability Notes
C
Cybersecurity and Infrastructure Security Agency CISA
S
Schneier on Security
S
Securelist
酷 壳 – CoolShell
酷 壳 – CoolShell
C
CXSECURITY Database RSS Feed - CXSecurity.com
Cyberwarzone
Cyberwarzone
Apple Machine Learning Research
Apple Machine Learning Research
S
SegmentFault 最新的问题
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
GbyAI
GbyAI
Security Latest
Security Latest
Last Week in AI
Last Week in AI
Microsoft Security Blog
Microsoft Security Blog
云风的 BLOG
云风的 BLOG
Recorded Future
Recorded Future
Webroot Blog
Webroot Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
TaoSecurity Blog
TaoSecurity Blog
C
Cisco Blogs
博客园 - 【当耐特】
Blog — PlanetScale
Blog — PlanetScale
Hugging Face - Blog
Hugging Face - Blog
B
Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Attack and Defense Labs
Attack and Defense Labs
The Last Watchdog
The Last Watchdog
U
Unit 42
阮一峰的网络日志
阮一峰的网络日志
Project Zero
Project Zero
WordPress大学
WordPress大学
L
LINUX DO - 最新话题
F
Fortinet All Blogs
L
LINUX DO - 热门话题
PCI Perspectives
PCI Perspectives
Simon Willison's Weblog
Simon Willison's Weblog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
MongoDB | Blog
MongoDB | Blog
Latest news
Latest news
P
Proofpoint News Feed
T
Threat Research - Cisco Blogs
The Hacker News
The Hacker News
爱范儿
爱范儿
O
OpenAI News
J
Java Code Geeks
T
The Exploit Database - CXSecurity.com
H
Hackread – Cybersecurity News, Data Breaches, AI and More

博客园 - x3d

deepin 23 一个可用 mysql-workbench 版本 8.0.36 基于 Maxwell 实现 MySQL 数据实时迁移到 Mongodb 本地开发环境 通过Podman 手动从头搭建 Ubuntu 容器镜像 intel ax203/ax201 无线网卡驱动 firmware 居然有问题 Direct firmware load for iwlwifi-bz-b0-hr-b0-94.ucode failed with error -2 近期不要选aliyun cloud linux 镜像 一点 PHP 中优雅的将JSON/XML/YAML 等数据反序列化成指定的类对象 开始收割了 PHP Composer 虚拟依赖包 - 实现按需载入钉钉对应功能模块的 php sdk 盘点之原地踏步三 盘点之原地踏步二 盘点之原地踏步一:weui 的一点探索 apijson 初探 Apache Synapse ESB erupt api Think3 ORM 《超文本和超链接》的时间线整理 MEAF框架概念检索工具 现代企业架构框架MEAF初次解读
在安卓平板上搭建 webdav 服务
x3d · 2023-10-22 · via 博客园 - x3d

早上醒来,脑子里又冒出来要搭建一个 webdav 服务以便尝试各种非云服务模式的笔记客户端的念头。于是任性的尝试起来。

在自己的华为matepad安卓平板上进行的。

搭建 Linux 模拟环境

从 f-droid 应用市场中安装 termux app。

termux 带 包管理,而且有非常多的应用可用,甚至 nodejs。

安装好后,进入app,先开启内存卡文件访问权限

termux-setup-storage

开启 sshd 服务

安装 sshd ,设置当前用户密码,启动服务。

pkg install openssh

whoami 查看当前用户名

passwd 设置当前用户密码

sshd

ifconfig 查看ip


通过 ssh 客户端 就可以登录服务器了,默认端口是8022。如 ssh u0_a226@192.168.1.101 -p8022

ssh 登录后,就可以远程继续操作服务器,安装和配置服务。

安装 apache

因为 apache 内置了 webdav 模块,安装这一个东东就能实现需求。

pkg install apache2

先输入 httpd 先验证一下 apache 能否正常启动。默认出现 httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message 这样的提示,也是ok的。

配置文件中默认端口是 8080,因此可以用浏览器或者命令测试一下服务能否正常访问,地址如 http://192.168.1.101:8080/ ,页面输出 It works!

配置 webdav 服务

termux 中命令行有个环境变量 $PREFIX ,代表路径前缀 /data/data/com.termux/files/usr,可以降低敲命令时的负担。

比如,cd $PREFIX/etc/apache2/,实际进入的目录会是 /data/data/com.termux/files/usr/etc/apache2

需要操作的配置文件有两个。

  • etc/apache2/httpd.conf
  • etc/apache2/extra/httpd-dav.conf

配置过程主要参考 httpd-dav.conf 中的说明即可,先按其中要求依赖的模块修改 httpd.conf 文件,取消相应模块的注释并取消 httpd-dav.conf 这行的注释,然后执行密码生成命令,最后创建相应的文件存储目录。

各种 webdav 客户端用到的认证类型,有 basic - mod_auth_basic 和 digest - mod_auth_digest 两种, basic 居多,所以针对 httpd-dav.conf 默认的配置,复制了一段,用于实现 basic 模式的授权。

下例中,/uploads 路径对应 默认的 digest 认证,/webdavb 对应 basic 认证。

两种认证方式,用到的 密码生成工具也是不同的,digest 方式的如配置文件中所示,htdigest -c "/data/data/com.termux/files/usr/user.passwd" DAV-upload admin , basic 的则为 htpasswd -c "/data/data/com.termux/files/usr/webdavb.passwd" admin

最后还初始化对应的两个目录,mkdir。

#
# Distributed authoring and versioning (WebDAV)
#
# Required modules: mod_alias, mod_auth_digest, mod_authn_core, mod_authn_file,
#                   mod_authz_core, mod_authz_user, mod_dav, mod_dav_fs,
#                   mod_setenvif

# The following example gives DAV write access to a directory called
# "uploads" under the ServerRoot directory.
#
# The User/Group specified in httpd.conf needs to have write permissions
# on the directory where the DavLockDB is placed and on any directory where
# "Dav On" is specified.

DavLockDB "/data/data/com.termux/files/usr/var/DavLock"

Alias /uploads "/data/data/com.termux/files/usr/uploads"
Alias /webdavb "/data/data/com.termux/files/usr/webdavb"

<Directory "/data/data/com.termux/files/usr/uploads">
    Dav On

    AuthType Digest
    AuthName DAV-upload
    # You can use the htdigest program to create the password database:
    #   htdigest -c "/data/data/com.termux/files/usr/user.passwd" DAV-upload admin
    AuthUserFile "/data/data/com.termux/files/usr/user.passwd"
    AuthDigestProvider file

    # Allow universal read-access, but writes are restricted
    # to the admin user.
    <RequireAny>
        Require method GET POST OPTIONS
        Require user admin
    </RequireAny>
</Directory>


<Directory "/data/data/com.termux/files/usr/webdavb">
    Dav On

    AuthType Basic
    AuthName DAV-upload
    # You can use the htpasswd program to create the password database:
    #   htpasswd -c "/data/data/com.termux/files/usr/webdavb.passwd" admin
    AuthUserFile "/data/data/com.termux/files/usr/webdavb.passwd"

    # Allow universal read-access, but writes are restricted
    # to the admin user.
    <RequireAny>
        Require method GET POST OPTIONS
        Require user admin
    </RequireAny>
</Directory>