企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# Frps服务端一键安装脚本 参考网址: [https://blog.csdn.net/Inke88/article/details/76677956](https://blog.csdn.net/Inke88/article/details/76677956) ### **注意事项:记得给使用的端口开放防火墙,开放防火墙,开放防火墙** 案例: 放开的端口号:6443、5334、9980 Frps服务端一键配置脚本地址:[https://github.com/MvsCode/frps\-onekey](https://github.com/MvsCode/frps-onekey) 脚本有两个源,国外VPS可以用Github的源,国内的VPS建议使用Aliyun的源,要不可能很慢。本教程使用的就是Aliyun的源 ~~~bash #下载脚本 wget https://code.aliyun.com/MvsCode/frps-onekey/raw/master/install-frps.sh -O ./install-frps.sh #设置脚本运行权限 chmod 700 ./install-frps.sh #执行脚本 ./install-frps.sh install #卸载 ./install-frps.sh uninstall #管理 /etc/init.d/frps start /etc/init.d/frps stop /etc/init.d/frps restart /etc/init.d/frps status /etc/init.d/frps config /etc/init.d/frps version ~~~ github地址: ### https://github.com/fatedier/frp 客户端下载地址: [Releases · fatedier/frp · GitHub](https://github.com/fatedier/frp/releases) 1、选择源,1是Aliyun,2是Github。我们选1 ![](https://pic3.zhimg.com/v2-a201be83241107721222ca571e7685de_r.jpg) 2、选择服务端口。默认是5443。这个端口的作用是在客户端连接服务端时是通过这个端口连接的。可以不用修改 ![](https://pic3.zhimg.com/v2-3b1eec6526982e5d75061ed9f94e83b6_r.jpg) 3、设置http连接的端口。默认80,没有被占用就默认 ![](https://pic2.zhimg.com/80/v2-c5d873c66ee1e8e4083fe5c2f9ea7d01_720w.png) 4、设置https连接的端口。默认443,没有被占用就默认 ![](https://pic3.zhimg.com/80/v2-50cab3192ab9e88405b8019ed951719e_720w.png) 5、设置面板的端口。直接用默认端口6443 ![](https://pic1.zhimg.com/80/v2-90eca02ad46426d6b5e7b6a55a160ae8_720w.png) 6、设置登录面板的用户名和密码,根据个人喜好设置 ![](https://pic3.zhimg.com/80/v2-ae9c9fb472542a220bd82b91a7e9e232_720w.png) ![](https://pic1.zhimg.com/80/v2-7f8e7c81e407691818b8102b2300b2f0_720w.png) 7、设置token。客户端需要填写的 ![](https://pic2.zhimg.com/80/v2-6df6e56d029f9e3ca6442013d3d404e9_720w.png) 8、设置域名,如果有就填写,没有就默认IP ![](https://pic2.zhimg.com/80/v2-3f7d85cd1f333e4b7b235ed812d2719d_720w.png) **其他的配置就默认就好** 安装好之后可以通过 frps config 指令修改或者查看配置。所以忘记了不怕 9、启动服务 ~~~text frps start ~~~ 最后,在浏览器中输入[http://ip:6443](http://ip:6443/)。如果打不开,请看看是不是VPS的防火墙没有开放6443端口。 如果成功就能看到如下的界面 ![](https://pic2.zhimg.com/v2-b3c544c0c97ee66b761d8c84c25fb739_r.jpg) ### 启动服务端 frps: ~~~ ./frps -c ./frps.ini ~~~ 查看`frp`进程 ~~~ ps -aux | grep frp ~~~ ### **客户端配置文件:** **frpc.ini** ~~~ [common] # 服务器地址 server_addr =192.168.0.0 # 服务器端口 server_port = 5443 # 服务器连接凭证 token = otkentiejsdlfasdl;f [web01] type = http local_port = 80 remote_port = 9980 custom_domains = a.frp.baidu.com host_header_rewrite = bd.cc [web02] type = http local_port = 80 remote_port = 9980 custom_domains = b.frp.baidu.com host_header_rewrite = localhost [web02_port] type = http local_ip = 127.0.0.1 local_port = 8686 remote_port = 9980 custom_domains = ha.frp.aaa.com ~~~ **Nginx端口映射:** 修改服务器的nginx配置: ~~~ map $http_x_forwarded_for $clientRealip { "" $remote_addr; ~^(?P<firstAddr>[0-9\.]+),?.*$ $firstAddr; } server { listen 80; server_name frp.baidu.com *.frp.baidu.com; location / { proxy_pass http://127.0.0.1:9980; #此处的9980就是你安装frp时设置的vhost_http_port端口 proxy_set_header Host $host; proxy_set_header X-Real-IP $clientRealip; # $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } ~~~