参考:

前提:

  • 一个带有公网IP的服务器
  • 一台内网电脑

下载地址:https://github.com/fatedier/frp/releases

本以为会很复杂,没想到真的超级简单,超级简单。

服务端

脚本安装

1、root用户登录

  1. wget https://code.aliyun.com/MvsCode/frps-onekey/raw/master/install-frps.sh -O ./install-frps.sh
  2. chmod 700 ./install-frps.sh
  3. ./install-frps.sh install

2、配置各项端口、token、界面用户名和密码、日志等等。

3、管理

  1. frps {start|stop|restart|status|config|version}
  2. # 卸载
  3. ./install-frps.sh uninstall
  4. # 更新
  5. ./install-frps.sh update

手动安装

1、下载

  1. ├── frps//服务端
  2. ├── frps_full.ini
  3. ├── frps.ini//服务端配置

2、配置

简单配置

  1. [common]
  2. #服务端口
  3. bind_port = 7000
  4. #监听地址
  5. bind_addr = 0.0.0.0
  6. #认证token
  7. token = big_cat
  8. #http服务端口
  9. vhost_http_port = 7080
  10. #https服务端口
  11. vhost_https_port = 70443

复杂配置,带有日志、面板等等。

  1. # [common] is integral section
  2. [common]
  3. # A literal address or host name for IPv6 must be enclosed
  4. # in square brackets, as in "[::1]:80", "[ipv6-host]:http" or "[ipv6-host%zone]:80"
  5. bind_addr = 0.0.0.0
  6. bind_port = 8001
  7. # udp port used for kcp protocol, it can be same with 'bind_port'
  8. # if not set, kcp is disabled in frps
  9. kcp_bind_port = 8001
  10. # if you want to configure or reload frps by dashboard, dashboard_port must be set
  11. dashboard_port = 8004
  12. # dashboard assets directory(only for debug mode)
  13. dashboard_user = xxx
  14. dashboard_pwd = xxx
  15. # assets_dir = ./static
  16. vhost_http_port = 8002
  17. vhost_https_port = 8003
  18. # console or real logFile path like ./frps.log
  19. log_file = ./frps.log
  20. # debug, info, warn, error
  21. log_level = info
  22. log_max_days = 3
  23. # auth token
  24. token = ppp
  25. # It is convenient to use subdomain configure for http、https type when many people use one frps server together.
  26. subdomain_host = soft.tianyunperfect.cn
  27. # only allow frpc to bind ports you list, if you set nothing, there won't be any limit
  28. #allow_ports = 1-65535
  29. # pool_count in each proxy will change to max_pool_count if they exceed the maximum value
  30. max_pool_count = 50
  31. # if tcp stream multiplexing is used, default is true
  32. tcp_mux = true

3、启动

  1. nohup ./frps -c ./frps.ini &

客户端

1、下载

  1. ├── frpc //客户端
  2. ├── frpc_full.ini
  3. ├── frpc.ini//客户端配置

2、配置

  1. [common]
  2. server_addr = soft.yyy.cn
  3. server_port = 8001
  4. token = ppp
  5. [ssh]
  6. type = tcp
  7. local_ip = 127.0.0.1
  8. local_port = 22
  9. remote_port = 6000
  10. [web]
  11. type = http
  12. local_port = 5000
  13. custom_domains = soft.yyy.cn

可以配置多个ssh和多个web,可能需要多个web

  1. [ssh001] # 不能重复
  2. type = tcp
  3. local_ip = 127.0.0.1
  4. local_port = 22
  5. remote_port = 6009 # 不能重复
  6. [web01]
  7. type = http
  8. local_port = 8080
  9. custom_domains = www.chendahai.cn
  10. [web02]
  11. type = http
  12. local_port = 80
  13. custom_domains = cd.chendahai.cn # 使用二级域名进行配置来区分

方法二,不需要多个二级域名,就是新建一个tcp连接

  1. [web]
  2. type = http
  3. local_port = 5000
  4. custom_domains = soft..cn
  5. [Beta]
  6. type = tcp
  7. local_ip = 127.0.0.1
  8. local_port = 5000
  9. remote_port = 8005

3、启动

4、访问:域名+port