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

这个示例通过配置 static_file 客户端插件来将本地文件暴露在公网上供其他人访问。

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

  1. frps.ini 内容如下:

    1. [common]
    2. bind_port = 7000
  2. frpc.ini 内容如下:

    1. [common]
    2. server_addr = x.x.x.x
    3. server_port = 7000
    4. [test_static_file]
    5. type = tcp
    6. remote_port = 6000
    7. plugin = static_file
    8. # 要对外暴露的文件目录
    9. plugin_local_path = /tmp/file
    10. # 用户访问 URL 中会被去除的前缀,保留的内容即为要访问的文件路径
    11. plugin_strip_prefix = static
    12. plugin_http_user = abc
    13. plugin_http_passwd = abc
  3. 分别启动 frps 和 frpc。

  4. 通过浏览器访问 http://x.x.x.x:6000/static/ 来查看位于 /tmp/file 目录下的文件,会要求输入已设置好的用户名和密码。

最后修改 March 19, 2021: update docs (f1b297a)