n1备忘笔记
安装docker
curl -fsSL https://get.docker.com | bash
systemctl start docker
service docker start
systemctl enable docker.service
systemctl status docker.service
webdav
cd /usr/local/webdav
wget https://hub.fastgit.org/hacdias/webdav/releases/download/v4.1.1/linux-arm64-webdav.tar.gz
tar -xvzf linux-arm64-webdav.tar.gz
vi /usr/local/webdav/config.yaml
# Server related settings
address: 0.0.0.0
port: 15108
auth: true
tls: false
cert: cert.pem
key: key.pem
# Default user settings (will be merged)
scope: .
modify: true
rules: []
users:
- username: user1
password: password1
scope: /data/webdav/dir1
创建服务项, 使得可以使用systemctl
控制服务
vi /usr/lib/systemd/system/webdav.service
[Unit]
Description=WebDAV server
After=network.target
[Service]
Type=simple
User=root
ExecStart=/usr/local/webdav/webdav --config /usr/local/webdav/config.yaml
Restart=on-failure
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable webdav
systemctl start webdav
docker 换源
使用场景: 拉取镜像报错, 但网是通的
vi /etc/docker/daemon.json
{
"registry-mirrors": ["https://bytkgxyr.mirror.aliyuncs.com","https://registry.docker-cn.com","http://hub-mirror.c.163.com"],
"live-restore": true
}
docker webdav-aliyundriver
获取refreshToken
docker run -d --name=webdav-aliyundriver --restart=always -p 38080:8080 -v /etc/localtime:/etc/localtime -v /etc/aliyun-driver/:/etc/aliyun-driver/ -e TZ="Asia/Shanghai" -e ALIYUNDRIVE_REFRESH_TOKEN="1f39cc0494dd4deab22c96771b6c5ccb" -e ALIYUNDRIVE_AUTH_PASSWORD="admin" -e JAVA_OPTS="-Xmx1g" zx5253/webdav-aliyundriver
# 将your refreshToken替换为上面获取的refreshToken
# 8080:8080 第一个8080为服务器webdav服务的端口,可修改
# /etc/aliyun-driver/ 挂载卷自动维护了最新的refreshToken,建议挂载
# ALIYUNDRIVE_AUTH_PASSWORD 是admin账户的密码,建议修改
# JAVA_OPTS 可修改最大内存占用,比如 -e JAVA_OPTS="-Xmx512m" 表示最大内存限制为512m
挂载WebDav方法
yum -y install davfs2
sed -i 's/# use_locks 1/use_locks 0/g' /etc/davfs2/davfs2.conf
echo "192.168.1.70:15108 user1 password1" >> /etc/davfs2/secrets #保存用户名密码,以后可以直接免密码挂载
mount.davfs 192.168.1.70:15108 /aliyun
echo "mount.davfs 192.168.1.70:15108 /aliyun" >> /etc/rc.local # 开机自动挂载
一些nginx骚操作
- 使用Nginx进行TCP/UDP/IPV6端口转发
要在编译安装时添加stream模块, 亲测宝塔的编译安装会安装此模块
vi nginx.conf # nginx主配置文件
stream { #将12345端口转发到192.168.1.23的3306端口 server { listen 12345; proxy_connect_timeout 5s; proxy_timeout 20s; proxy_pass 192.168.1.23:3306; } #将udp 53端口转发到192.168.1.23 53端口 server { listen 53 udp reuseport; proxy_timeout 20s; proxy_pass 192.168.1.23:53; } #ipv4转发到ipv6 server { listen 9135; proxy_connect_timeout 10s; proxy_timeout 30s; proxy_pass [2607:fcd0:107:3cc::1]:9135; }}
nginx -s reload
- nginx代理socket端口
要在编译安装时添加stream模块, 亲测宝塔的编译安装会安装此模块
vi nginx.conf # nginx主配置文件
stream{ upstream socket_server{ server 127.0.0.1:3802 weight=1;#发布socket1服务端口 server 127.0.0.1:3803 weight=1;#发布socket2服务端口 } #监听socket端口 server { listen 3801; proxy_pass socket_server; }}
nginx -s reload
至于用处嘛, 当然是让只有ipv4的设备使用上ipv6的ss
虽然有点多此一举, 但众所周知, ipv4的ss容易被封, 本人一台vultr的ss, ipv6正常, 换成ipv4就不能使用, (怀疑是某些端口被封)
通过一个双栈的nginx就可以将ss的ipv6转换成本地的ipv4