内网穿透frp部署
前置条件:公网固定ip的服务器一台
frp下载地址: https://github.com/fatedier/frp/releases
frp是golang开发的项目,release里面有预编译好的二进制,可直接部署。
当前版本为frp_0.61.0
服务端
云服务器需开放7000端口,供frp客户端访问。frps.toml配置参考如下:# listen to client bindPort = 7000 # server dashboard webServer.port = 7500 webServer.user = "xxx" # change for yourself webServer.password = "pass_word" # change for yourself # auth auth.method = "token" auth.token = "token_string" # change for yourself
启动命令
./frpc -c frpc.toml
。客户端
客户端配置frpc.toml如下:serverAddr = "xxx.xxx.xx.xx" # change for yourself serverPort = 7000 # auth auth.method = "token" auth.token = "token_string" # same with frps server [[proxies]] name = "item name" # change for yourself type = "tcp" localIP = "127.0.0.1" # change for yourself localPort = 3030 # change for yourself (client side port) remotePort = 3030 # change for yourself (server side port)
启动命令
./frpc -c frpc.toml
。Mac系统登录自启动方案
添加启动配置文件sudo vim /Library/LaunchDaemons/frpc.plist
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd > <plist version="1.0"> <dict> <key>Label</key> <string>frpc</string> <key>ProgramArguments</key> <array> <string>/xxx/frp/frpc</string> <string>-c</string> <string>/xxx/frp/frpc.toml</string> </array> <key>KeepAlive</key> <true/> <key>RunAtLoad</key> <true/> </dict> </plist>
注意替换配置中的路径,使用命令
sudo launchctl load -w /Library/LaunchDaemons/frpc.plist
启用登录配置
参考:https://blog.csdn.net/qq_36348557/article/details/130522157