FRP 内网穿透
外网访问vpsIP:8080转发到本地:80
一、服务端配置(Ubuntu 云服务器)
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| wget https://github.com/fatedier/frp/releases/download/v0.61.2/frp_0.61.2_linux_amd64.tar.gz tar -zxvf frp_0.61.2_linux_amd64.tar.gz mv frp_0.61.2_linux_amd64 /opt/frp cd /opt/frp
cat > frps.toml << 'EOF' bindPort = 7000 auth.method = "token" auth.token = "dsjahdjkahkk" vhostHTTPPort = 8080 log.to = "console" log.level = "info" EOF
sudo ufw allow 7000/tcp sudo ufw allow 8080/tcp
cat > /etc/systemd/system/frps.service << 'EOF' [Unit] Description=Frp Server Service After=network.target
[Service] Type=simple Restart=always RestartSec=5 ExecStart=/opt/frp/frps -c /opt/frp/frps.toml
[Install] WantedBy=multi-user.target EOF
sudo systemctl daemon-reload sudo systemctl start frps sudo systemctl enable frps sudo systemctl status frps
|
二、客户端配置(Anolis 本地机器)
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| wget https://github.com/fatedier/frp/releases/download/v0.61.2/frp_0.61.2_linux_amd64.tar.gz tar -zxvf frp_0.61.2_linux_amd64.tar.gz mv frp_0.61.2_linux_amd64 /opt/frp cd /opt/frp
cat > frpc.toml << 'EOF' serverAddr = "12.34.56.78" serverPort = 7000 auth.token = "dsjahdjkahkk"
[[proxies]] name = "web" type = "http" localPort = 80 customDomains = ["12.34.56.78"] httpUser = "username" httpPassword = "password" EOF
./frpc -c frpc.toml
cat > /etc/systemd/system/frpc.service << 'EOF' [Unit] Description=Frp Client Service After=network.target
[Service] Type=simple Restart=always RestartSec=5 ExecStart=/opt/frp/frpc -c /opt/frp/frpc.toml
[Install] WantedBy=multi-user.target EOF
sudo systemctl daemon-reload sudo systemctl start frpc sudo systemctl enable frpc sudo systemctl status frpc
|
三、云服务商安全组配置
登录云控制台,添加入方向规则:
| 协议 |
端口 |
来源 |
| TCP |
7000 |
0.0.0.0/0 |
| TCP |
8080 |
0.0.0.0/0 |
四、验证访问
1 2 3 4 5 6 7
| sudo systemctl status frps sudo systemctl status frpc
sudo journalctl -u frps -f sudo journalctl -u frpc -f
|
浏览器访问:http://68.64.178.45:8080(输入 HTTP Basic Auth 用户名密码)
五、常用管理命令
1 2 3 4 5 6 7 8 9 10 11 12
| sudo systemctl start frps/frpc sudo systemctl stop frps/frpc sudo systemctl restart frps/frpc sudo systemctl status frps/frpc
sudo journalctl -u frps/frpc -f sudo journalctl -u frps/frpc -n 50
sudo systemctl restart frps/frpc
|