背景
大学时候用的笔记本已经很旧了, 所以将它作为服务器。因为我有自己的 vps 和域名, 所以使用 frp 作为穿透工具。目的是, 可以通过外网 ssh, 还有可以作为 web 服务器使用。
安装 debian 13 之后, 安装无线网卡驱动, 并连接 wifi
安装 NetworkManager (个人爱好):
1
apt install cockpit-networkmanager
查看网卡型号:
1
2
# Broadcom Inc. and subsidiaries BCM43142 802.11b/g/n (rev 01)
lspci | grep -i network
因为 BCM43142 需要 broadcom-sta-dkms, 所以:
/etc/apt/sources.list 添加: 1
2
deb http://deb.debian.org/debian/ trixie contrib main non-free-firmware non-free
deb-src http://deb.debian.org/debian/ trixie contrib main non-free-firmware non-free
安装: 1
2
3
4
5
6
apt update
apt install linux-headers-$(uname -r)
apt install broadcom-sta-dkms
modprobe wl
systemctl restart NetworkManager
连接 wifi:
配置笔记本合上盒子不睡眠
/etc/systemd/logind.conf:
1
2
HandleLidSwitch=suspend
HandleLidSwitchExternalPower=lock
1
systemctl status systemd-logind
配置 ssh
See 禁用SSH密码认证并启用密钥认证
配置 frp
vps
1
wget https://github.com/fatedier/frp/releases/download/v0.69.1/frp_0.69.1_linux_amd64.tar.gz
/opt/frps:
1
2
3
/opt/frps/
├── frps
└── frps.toml
frps.toml:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
bindPort = 7000
vhostHTTPSPort = 8443 # 因为 nginx 占用了 443, 所以直接用 8443 算了
[ auth ]
method = "token"
token = "xxx"
# Web 管理界面(可选)
[ webServer ]
addr = "0.0.0.0"
port = 7500
user = "xxx"
password = "@xxx"
# 日志配置
[ log ]
to = "./frps.log"
level = "info"
maxDays = 7
/etc/systemd/system/frpc.servie:
1
2
3
4
5
6
7
8
9
10
11
12
13
[Unit]
# Service name, customizable
Description = frp server
After = network.target syslog.target
Wants = network.target
[Service]
Type = simple
# Command to start frps, modify to your frps installation path
ExecStart = /opt/frps/frps -c /opt/frps/frps.toml
[Install]
WantedBy = multi-user.target
Enable and start the frps service:
1
2
3
systemctl daemon-reload
systemctl start frps
systemctl enable frps
旧笔记本
1
wget https://github.com/fatedier/frp/releases/download/v0.69.1/frp_0.69.1_linux_amd64.tar.gz
/opt/frps:
1
2
3
/opt/frpc/
├── frpc
└── frpc.toml
frpc.toml:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
serverAddr = "foo.domain.com"
serverPort = 7000
auth . token = "xxx" # 和 server 的一样
[[ proxies ]]
name = "ssh"
type = "tcp"
localIP = "127.0.0.1"
localPort = 22
remotePort = 6000
[[ proxies ]]
name = "test_htts2http"
type = "https"
customDomains = [ "foo.domain.com" ]
[ proxies . plugin ]
type = "https2http"
localAddr = "127.0.0.1:8443"
# HTTPS certificate related configuration
crtPath = "xxx/fullchain.pem"
keyPath = "xxx/private.pem"
hostHeaderRewrite = "127.0.0.1"
requestHeaders . set . x-from-where = "frp"
/etc/systemd/system/frpc.servie:
1
2
3
4
5
6
7
8
9
10
11
[Unit]
Description = frp client
After = network.target syslog.target
Wants = network.target
[Service]
Type = simple
ExecStart = /opt/frpc/frpc -c /opt/frpc/frpc.toml
[Install]
WantedBy = multi-user.target
Enable and start the frpc service:
1
2
3
systemctl daemon-reload
systemctl start frpc
systemctl enable frpc
在 nginx 中配置 domain 的 website. /etc/nginx/site-available/foo.domain.com:
1
2
3
4
5
6
7
8
9
server {
listen 127.0 . 0.1 : 8443 ;
listen [:: 1 ]: 8443 ;
root / var / www / foo . domain . com / html ;
access_log / var / log / nginx / foo . domain . com . access . log ;
error_log / var / log / nginx / foo . domain . com . error . log ;
}
1
2
3
ln -sf /etc/nginx/site-availables/foo.domain.com /etc/nginx/site-enable/foo.domain.com
nginx -t
systemctl relod nginx
acme + cloudflare 申请证书的工具: acme-cloudflare
记得在 cloudflare 添加 domain 的 dns 记录。
验证:
1
2
ssh ...
curl https://foo.domain.com:8443
References