参考:
前提:
- 一个带有公网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.sh
chmod 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
#认证token
token = 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.0
bind_port = 8001
# udp port used for kcp protocol, it can be same with 'bind_port'
# if not set, kcp is disabled in frps
kcp_bind_port = 8001
# if you want to configure or reload frps by dashboard, dashboard_port must be set
dashboard_port = 8004
# dashboard assets directory(only for debug mode)
dashboard_user = xxx
dashboard_pwd = xxx
# assets_dir = ./static
vhost_http_port = 8002
vhost_https_port = 8003
# console or real logFile path like ./frps.log
log_file = ./frps.log
# debug, info, warn, error
log_level = info
log_max_days = 3
# auth token
token = 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 value
max_pool_count = 50
# if tcp stream multiplexing is used, default is true
tcp_mux = true
3、启动
nohup ./frps -c ./frps.ini &
客户端
1、下载
├── frpc //客户端
├── frpc_full.ini
├── frpc.ini//客户端配置
2、配置
[common]
server_addr = soft.yyy.cn
server_port = 8001
token = ppp
[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6000
[web]
type = http
local_port = 5000
custom_domains = soft.yyy.cn
可以配置多个ssh和多个web,可能需要多个web
[ssh001] # 不能重复
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6009 # 不能重复
[web01]
type = http
local_port = 8080
custom_domains = www.chendahai.cn
[web02]
type = http
local_port = 80
custom_domains = cd.chendahai.cn # 使用二级域名进行配置来区分
方法二,不需要多个二级域名,就是新建一个tcp连接
[web]
type = http
local_port = 5000
custom_domains = soft..cn
[Beta]
type = tcp
local_ip = 127.0.0.1
local_port = 5000
remote_port = 8005
3、启动
4、访问:域名+port