九、frp对外提供简单的文件访问服务

通过 static_file 插件可以对外提供一个简单的基于 HTTP 的文件访问服务。类似于http的文件索引!


服务端frps.ini配置
[common]
bind_addr = 0.0.0.0
bind_port = 7000
privilege_token = 12345678


客户端frpc.ini配置
[common]
server_addr = 服务端IP
server_port = 7000
privilege_token = 12345678


[static_file]
type = tcp
local_ip = 127.0.0.1
remote_port = 6000
plugin = static_file
plugin_local_path = /tmp/file
plugin_strip_prefix = static
plugin_http_user = admin
plugin_http_passwd = admin

static_file 插件参数详解
plugin = static_file为开启插件static_file模式
plugin_local_path文件目录的绝对路径
plugin_strip_prefix访问网址后缀路径
通过浏览器访问 http://x.x.x.x:6000/static/
来查看位于 /tmp/file 目录下的文件,如不需要,可以不添加此参数。
plugin_http_user为http访问验证的用户名,可自定义,可添加此参数或不添加。
plugin_http_passwd为http访问验证的密码,可自定义,可添加此参数或不添加。


注意:客户端访问时需要加上端口号,每个客户端使用的端口号均不能相同

 

实际配置

frps服务端配置(linux系统)
[root@hn frps]# cat frps.ini
[common]
bind_port = 7000
vhost_http_port = 8080
#vhost_https_port = 8080
dashboard_port = 7500
# dashboard 用户名密码,默认都为 admin
dashboard_user = admin
dashboard_pwd = admin
privilege_token = 12345678
privilege_allow_ports = 2000-3000
max_pool_count = 10
subdomain_host = 1.2.com
log_file = ./frps.log
log_level = info
log_max_days = 3

windows作为frpc客户端使用 =>访问地址:http://x.x.x.x:2900/static
[common]
server_addr = x.x.x.x  #frps服务端IP
server_port = 7000
privilege_token = 12345678 #校验
pool_count = 2
log_file = ./frpc.log
log_level = info
log_max_days = 3

[static_file]
type = tcp
local_ip = 127.0.0.1
remote_port = 2900  #frps服务端端口放行
plugin = static_file
plugin_local_path = D:/Py/10  #本机目录,注意写法
plugin_strip_prefix = static
plugin_http_user = admin  #账号
plugin_http_passwd = admin #密码

linux作为frpc客户端使用  =>访问地址:http://x.x.x.x:2002/static
[common]
server_addr = x.x.x.x
server_port = 7000
privilege_token = 12345678
pool_port = 2
log_file = ./frpc.log
log_level = info
log_max_days = 3

[plugin_static_file]
type = tcp
remote_port = 2002
plugin = static_file
plugin_local_path = /tmp/file
plugin_strip_prefix = static
plugin_http_user = abc
plugin_http_passwd = abc

posted @ 2018-03-05 15:25  哈喽哈喽111111  阅读(2266)  评论(0编辑  收藏  举报