参考:
前提:
- 一个带有公网IP的服务器
- 一台内网电脑
下载地址:https://github.com/fatedier/frp/releases
服务端
脚本安装
1、root用户登录
wget https://code.aliyun.com/MvsCode/frps-onekey/raw/master/install-frps.sh -O ./install-frps.shchmod 700 ./install-frps.sh./install-frps.sh install
2、配置各项端口、token、界面用户名和密码、日志等等。
3、管理
frps {start|stop|restart|status|config|version}# 卸载./install-frps.sh uninstall# 更新./install-frps.sh update
手动安装
1、下载
├── frps//服务端├── frps_full.ini├── frps.ini//服务端配置
2、配置
简单配置
[common]#服务端口bind_port = 7000#监听地址bind_addr = 0.0.0.0#认证tokentoken = big_cat#http服务端口vhost_http_port = 7080#https服务端口vhost_https_port = 70443
复杂配置,带有日志、面板等等。
# [common] is integral section[common]# A literal address or host name for IPv6 must be enclosed# in square brackets, as in "[::1]:80", "[ipv6-host]:http" or "[ipv6-host%zone]:80"bind_addr = 0.0.0.0bind_port = 8001# udp port used for kcp protocol, it can be same with 'bind_port'# if not set, kcp is disabled in frpskcp_bind_port = 8001# if you want to configure or reload frps by dashboard, dashboard_port must be setdashboard_port = 8004# dashboard assets directory(only for debug mode)dashboard_user = xxxdashboard_pwd = xxx# assets_dir = ./staticvhost_http_port = 8002vhost_https_port = 8003# console or real logFile path like ./frps.loglog_file = ./frps.log# debug, info, warn, errorlog_level = infolog_max_days = 3# auth tokentoken = ppp# It is convenient to use subdomain configure for httpăhttps type when many people use one frps server together.subdomain_host = soft.tianyunperfect.cn# only allow frpc to bind ports you list, if you set nothing, there won't be any limit#allow_ports = 1-65535# pool_count in each proxy will change to max_pool_count if they exceed the maximum valuemax_pool_count = 50# if tcp stream multiplexing is used, default is truetcp_mux = true
3、启动
nohup ./frps -c ./frps.ini &
客户端
1、下载
├── frpc //客户端├── frpc_full.ini├── frpc.ini//客户端配置
2、配置
[common]server_addr = soft.yyy.cnserver_port = 8001token = ppp[ssh]type = tcplocal_ip = 127.0.0.1local_port = 22remote_port = 6000[web]type = httplocal_port = 5000custom_domains = soft.yyy.cn
可以配置多个ssh和多个web,可能需要多个web
[ssh001] # 不能重复type = tcplocal_ip = 127.0.0.1local_port = 22remote_port = 6009 # 不能重复[web01]type = httplocal_port = 8080custom_domains = www.chendahai.cn[web02]type = httplocal_port = 80custom_domains = cd.chendahai.cn # 使用二级域名进行配置来区分
方法二,不需要多个二级域名,就是新建一个tcp连接
[web]type = httplocal_port = 5000custom_domains = soft..cn[Beta]type = tcplocal_ip = 127.0.0.1local_port = 5000remote_port = 8005
3、启动
4、访问:域名+port
