Note/环境/安装教程/内网穿透.md

210 lines
3.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

在GitHub上下载对应版本的frp程序然后上传frps到服务器
下载地址https://github.com/fatedier/frp/releases
文档地址
```shell
#直接下载指定版本
wget https://github.com/fatedier/frp/releases/download/v0.53.2/frp_0.53.2_linux_amd64.tar.gz
```
#### 解压
```shell
tar -xzvf frp_0.53.2_linux_amd64.tar.gz
```
#### 复制
```shell
cp -R /root/frp_0.53.2_linux_amd64/* /root/
```
## 服务端
#### 测试运行
```shell
chmod +x frps
./frps
```
#### 运行配置
```shell
vim frps.toml
```
配置文件如下
```properties
bindPort = 7000 #注册服务端口
auth.method = "token" #验证方式
auth.token = "token" #token秘钥
webServer.port = 7500 #管理面板端口
webServer.addr = "0.0.0.0" #绑定到所有网络上,外网访问
webServer.user = "admin" #管理员名称
webServer.password = "admin" #管理员密码
```
上面是带有备注(运行时好像不能带有备注,后面两个的均为该行为)
```properties
bindPort = 7000
auth.method = "token"
auth.token = "token"
webServer.port = 7500
webServer.addr = "0.0.0.0"
webServer.user = "admin"
webServer.password = "admin"
```
#### 启动
```shell
./frps -c frps.toml
```
#### 配置为Linux服务的形式运行
```shell
sudo vim /etc/systemd/system/frps.service
```
配置文件如下
```properties
[Unit]
Description = frp server
After = network.target syslog.target
Wants = network.target
[Service]
Type = simple
ExecStart = /root/frps -c /root/frps.toml
[Install]
WantedBy = multi-user.target
```
#### 启动
```shell
systemctl enable frps
systemctl start frps
```
## 客户端
#### 测试运行
```shell
chmod +x frpc
./frpc
```
#### 运行配置
```shell
vim frpc.toml
```
配置文件如下
```properties
serverAddr = "1.1.1.1" //之前搭建好的内网穿透服务器地址
serverPort = 7000 //内网穿透服务器注册端口
auth.method = "token" //使用token验证
auth.token = "123456" //使用密码
[[proxies]]
name = "nginx" //配置需要代理的本地服务
type = "tcp" //类型选择tcp即可大部分都是
localIP = "127.0.0.1" //本地服务的IP地址因为是直接部署在本地所以说直接127.0.0.1
localPort = 80 //本地服务端口
remotePort = 80 //远程代理端口
```
```properties
serverAddr = "1.1.1.1"
serverPort = 7000
auth.method = "token"
auth.token = "123456"
[[proxies]]
name = "nginx"
type = "tcp"
localIP = "127.0.0.1"
localPort = 80
remotePort = 80
```
#### 启动
```shell
./frpc -c frpc.toml
```
#### 配置为Linux服务的形式运行
```shell
sudo vim /etc/systemd/system/frpc.service
```
配置文件如下
```properties
[Unit]
Description = frp client
After = network.target syslog.target
Wants = network.target
[Service]
Type = simple
ExecStart = /root/frpc -c /root/frpc.toml
[Install]
WantedBy = multi-user.target
```
#### 启动
```shell
systemctl enable frpc
systemctl start frpc
```
## 其他设置
#### 进程放到后台运行
通过下面命令启动
```shell
nohup ./frpc -c frpc.toml >/dev/null 2>&1 &
```
查看运行进程
```shell
ps aux | grep frpc
```
```shell
root@pve:~# ps aux | grep frpc
root 17856 0.0 0.0 724104 12160 pts/0 Sl 10:17 0:00 ./frpc -c frpc.toml
root 17903 0.0 0.0 6332 2048 pts/1 S+ 10:17 0:00 grep frpc
```
清除进程
```shell
kill 17856
```