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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & 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>