mirror of
https://github.com/Estom/notes.git
synced 2026-02-02 18:20:20 +08:00
将blog打包镜像
This commit is contained in:
6
Dockerfile
Normal file
6
Dockerfile
Normal file
@@ -0,0 +1,6 @@
|
||||
FROM node:20-alpine
|
||||
RUN npm install -g docsify-cli@latest
|
||||
WORKDIR /docs
|
||||
COPY . .
|
||||
EXPOSE 3000
|
||||
CMD ["docsify", "serve", ".", "--port", "3000"]
|
||||
31
MyScript/blog/run_blog.sh
Normal file
31
MyScript/blog/run_blog.sh
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
nohup docsify serve -p 80 /root/gitee/notes &> blog.log &
|
||||
|
||||
|
||||
# 使用容器的方式打包当前镜像
|
||||
docker build -t my-docsify-blog .
|
||||
|
||||
# 运行容器
|
||||
docker run -d --restart=always \
|
||||
--name docsify-blog \
|
||||
-p 3000:3000 \
|
||||
-v $(pwd):/docs \
|
||||
my-docsify-blog
|
||||
|
||||
|
||||
docker run --name docsify-blog \
|
||||
-p 3000:3000 \
|
||||
my-docsify-blog
|
||||
# 查看日志
|
||||
docker logs -f docsify-blog
|
||||
|
||||
# 停止 / 启动
|
||||
docker stop docsify-blog
|
||||
docker start docsify-blog
|
||||
|
||||
# 更新镜像后重新部署
|
||||
docker build -t my-docsify-blog .
|
||||
docker rm -f docsify-blog
|
||||
docker run -d ... # 同上
|
||||
|
||||
|
||||
21
MyScript/network/autossh.service
Normal file
21
MyScript/network/autossh.service
Normal file
@@ -0,0 +1,21 @@
|
||||
[Unit]
|
||||
Description=Robust SSH Reverse Tunnel and Port Forward
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User=estom
|
||||
# 使用绝对路径指定密钥(如果使用密钥认证)
|
||||
Environment="AUTOSSH_GATETIME=0"
|
||||
ExecStart=/usr/bin/autossh -M 0 -o "ExitOnForwardFailure=yes" -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -N -T -i /home/estom/.ssh/id_rsa -R 8000:localhost:22 root@8.141.4.34
|
||||
|
||||
# 关键修复参数
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
KillMode=process # 确保终止所有子进程
|
||||
|
||||
# 启动频率限制调整
|
||||
StartLimitIntervalSec=60
|
||||
StartLimitBurst=10
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
74
MyScript/network/clash.sh
Normal file
74
MyScript/network/clash.sh
Normal file
@@ -0,0 +1,74 @@
|
||||
# 配置信息
|
||||
/usr/local/bin/clash
|
||||
~/.config/clash/config.yaml
|
||||
|
||||
# clash默认监听的http/https端口
|
||||
127.0.0.1:7890
|
||||
# clash默认监听的socks5端口
|
||||
127.0.0.1:7891
|
||||
# clash默认的控制台端口
|
||||
:::9090
|
||||
|
||||
# 手动启动clash
|
||||
clash -d /etc/clash/config.yaml
|
||||
|
||||
|
||||
# 将clash设置为系统服务-暂不设置,容易出问题.
|
||||
# 当前已经自动启动了了服务sudo systemctl stop mihomo.service
|
||||
├─mihomo.service
|
||||
│ └─20307 /opt/clash/bin/mihomo -d /opt/clash -f /opt/clash/runtime.yaml
|
||||
|
||||
# 将http_proxy设置为当前shell的变量
|
||||
export http_proxy="http://127.0.0.1:7890"
|
||||
export https_proxy="http://127.0.0.1:7890"
|
||||
|
||||
# 将http_proxy设置为当前用户的变量
|
||||
# 将以下文件放到.bashrc中
|
||||
vi ~/.bashrc
|
||||
export http_proxy="http://127.0.0.1:7890"
|
||||
export https_proxy="http://127.0.0.1:7890"
|
||||
|
||||
|
||||
|
||||
# 【可选】将http_proxy设置为系统变量
|
||||
sudo vi /etc/environment
|
||||
|
||||
|
||||
# 如何关闭clash
|
||||
ps -ef | grep clash
|
||||
lsof -i:7890
|
||||
kill 12345
|
||||
|
||||
# 如何关闭代理
|
||||
unset http_proxy
|
||||
unset https_proxy
|
||||
|
||||
# 如果是通过服务启动的clash则需要通过服务管理命令关闭
|
||||
|
||||
sudo systemctl stop clash
|
||||
# 以下命令可以禁用开机启动
|
||||
sudo systemctl disable clash
|
||||
|
||||
# 如何配置git的代理
|
||||
git config --global http.proxy http://127.0.0.1:7890
|
||||
git config --global https.proxy http://127.0.0.1:7890
|
||||
git config --global http.proxy socks5://127.0.0.1:7891
|
||||
|
||||
|
||||
# 取消git的代理
|
||||
git config --global --unset http.proxy
|
||||
git config --global --unset https.proxy
|
||||
|
||||
|
||||
#如何设置ssh代理
|
||||
# ~/.ssh/config
|
||||
Host github.com
|
||||
HostName github.com
|
||||
User git
|
||||
# 使用 SOCKS5 代理(如 Clash/V2Ray)
|
||||
ProxyCommand nc -x 127.0.0.1:7891 %h %p
|
||||
# 或使用 HTTP 代理(需安装 proxychains)
|
||||
# ProxyCommand connect -H 127.0.0.1:7890 %h %p
|
||||
|
||||
# 自带的ui地址如下
|
||||
http://localhost:9090/ui/
|
||||
48
MyScript/network/frp-route.sh
Normal file
48
MyScript/network/frp-route.sh
Normal file
@@ -0,0 +1,48 @@
|
||||
# 这是另外一套内网穿透方案——frp
|
||||
# 客户端配置文件如下
|
||||
serverAddr = "8.141.4.34"
|
||||
serverPort = 7000
|
||||
auth.token = "ykl123"
|
||||
|
||||
[[proxies]]
|
||||
name = "ssh-tcp"
|
||||
type = "tcp"
|
||||
localIP = "127.0.0.1"
|
||||
localPort = 22
|
||||
remotePort = 6000
|
||||
|
||||
|
||||
|
||||
# 客户端服务文件如下
|
||||
[Unit]
|
||||
Description=Frp Client Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User=estom
|
||||
Type=simple
|
||||
ExecStart=/usr/local/bin/frpc -c /home/estom/.config/frp/frpc.toml
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
# 客户端配置命令如下
|
||||
sudo systemctl enable frpc
|
||||
sudo systemctl start frpc
|
||||
sudo systemctl status frpc
|
||||
|
||||
|
||||
# 服务端配置文件如下
|
||||
|
||||
[common]
|
||||
bind_port = 7000 # frp 客户端连接端口
|
||||
token = ykl123
|
||||
dashboard_port = 7500 # web 控制台端口(可选)
|
||||
dashboard_user = estom
|
||||
dashboard_pwd = ykl123
|
||||
|
||||
|
||||
# 服务端启动命令如下。服务端可以随时连接启动,不需要额外配置
|
||||
nohup ./frps -c frps.ini &
|
||||
13
MyScript/network/frpc.service
Normal file
13
MyScript/network/frpc.service
Normal file
@@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=Frp Client Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User=estom
|
||||
Type=simple
|
||||
ExecStart=/usr/local/bin/frpc -c /home/estom/.config/frp/frpc.toml
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
53
MyScript/network/ssh-route.sh
Normal file
53
MyScript/network/ssh-route.sh
Normal file
@@ -0,0 +1,53 @@
|
||||
# 使用ssh隧道远程转发,实现内网穿透
|
||||
# -N:不执行远程命令,仅用于转发。
|
||||
# -f:后台运行。
|
||||
# -R:远程转发(反向隧道)。
|
||||
# ssh -NfR 公网服务器端口:内网主机:内网端口 公网用户名@公网服务器IP
|
||||
ssh -NfR 8000:localhost:22 root@8.141.4.34
|
||||
|
||||
# 使用autossh实现ssh隧道远程转发,实现内网穿透,能够避免网络波动,实现自动重连
|
||||
# -M 0:不使用监控端口,通过 SSH 自身机制检测连接状态。
|
||||
autossh -M 0 -NfR 8000:localhost:22 root@8.141.4.34
|
||||
|
||||
# 为了执行autossh不需要远程认证需要将当前容器的ssh公钥添加到远程服务器的authorized_keys中
|
||||
ssh-copy-id root@8.141.4.34
|
||||
|
||||
# 需要配置公网服务器上开启远程转发服务
|
||||
GatewayPorts yes
|
||||
AllowTcpForwarding yes
|
||||
|
||||
# 配置完成后需要重启ssh服务
|
||||
sudo systemctl restart sshd
|
||||
|
||||
|
||||
# 如何关闭远程转发——本地端的ssh隧道
|
||||
ps aux | grep "ssh -NfR"
|
||||
kill 12345 # 替换为实际的 PID
|
||||
# 或者执行如下命令
|
||||
pkill -f "ssh -NfR"
|
||||
# 如果是autossh执行如下命令
|
||||
ps aux | grep autossh
|
||||
kill 12345 # 替换为实际的 PID
|
||||
|
||||
|
||||
# 关闭远程服务器的端口转发
|
||||
netstat -tulpn | grep 8000 # 替换为你转发的端口
|
||||
sudo kill 12345 # 替换为实际的 PID
|
||||
|
||||
|
||||
# 最后,远程连接的方式如下
|
||||
ssh -p 8000 estom@8.141.4.34
|
||||
|
||||
# 服务开机启动。去掉了-f参数不再是后台启动。服务本身就应该启动一个阻塞的命令。
|
||||
autossh.service
|
||||
|
||||
|
||||
# 修改service文件后可以这样保证配置文件生效
|
||||
# 1. 重新加载 systemd 管理器配置(使服务文件更改生效)
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
# 2. 重启特定服务
|
||||
sudo systemctl restart your-service-name.service
|
||||
|
||||
# 3. 检查服务状态
|
||||
sudo systemctl status your-service-name.service
|
||||
@@ -1,2 +0,0 @@
|
||||
|
||||
nohup docsify serve -p 80 /root/gitee/notes &> blog.log &
|
||||
Reference in New Issue
Block a user