frp
是一个快速反向代理服务,实现暴露NAT或防火墙后的内网服务到互联网。支持 TCP
、UDP
、HTTP
、HTTPS
、P2P
协议,请求可以通过域名转发到内网服务。
服务端frps部署
参考:使用Docker Compose管理多个容器
[common]
bind_port = {{ .Envs.FRP_SERVER_PORT }}
token = {{ .Envs.FRP_SERVER_TOKEN }}
dashboard_addr = 0.0.0.0
dashboard_port = {{ .Envs.FRP_DASHBOARD_PORT }}
# dashboard's username and password are both optional
dashboard_user = {{ .Envs.FRP_DASHBOARD_USER }}
dashboard_pwd = {{ .Envs.FRP_DASHBOARD_PASS }}
客户端认证方式支持:
Token Authentication,本示例
OIDC Authentication
配置 docker-compose.yml
version: "3.7"
services:
frps:
restart: always
container_name: frps
image: fatedier/frps:v0.38.0
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- ./frps.ini:/app/frps.ini:ro
command: -c /app/frps.ini
ports:
- 8022:8022
- 8080:8080
- 7000:7000
- 7500:7500
environment:
- FRP_SERVER_PORT=7000
- FRP_SERVER_TOKEN=xiexianbin
- FRP_DASHBOARD_PORT=7500
- FRP_DASHBOARD_USER=admin
- FRP_DASHBOARD_PASS=admin
logging:
driver: "json-file"
options:
max-size: "5m"
其中 8022
和 8080
为要代理出去的端口
docker-compose up -d
- 访问:
http://<frps-public-ip>:7500/
,密码为:<FRP_DASHBOARD_USER>/<FRP_DASHBOARD_PASS>
对应的值。
服务端frpc部署
[common]
server_addr = {{ .Envs.FRP_SERVER_ADDR }}
server_port = {{ .Envs.FRP_SERVER_PORT }}
token = {{ .Envs.FRP_SERVER_TOKEN }}
[app]
type = tcp
remote_port = {{ .Envs.REMOTE_PORT }}
local_ip = {{ .Envs.LOCAL_IP }}
local_port = {{ .Envs.LOCAL_PORT }}
# use_encryption = true
# use_compression = true
# tls_enable = true
version: "3.7"
services:
frpc:
restart: always
container_name: frpc
image: fatedier/frpc:v0.38.0
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- ./frpc.ini:/app/frpc.ini:ro
command: -c /app/frpc.ini
environment:
- FRP_SERVER_ADDR=<frps ip>
- FRP_SERVER_PORT=7000
- FRP_SERVER_TOKEN=xiexianbin
- REMOTE_PORT=8080
- LOCAL_IP=127.0.0.1
- LOCAL_PORT=8080
logging:
driver: "json-file"
options:
max-size: "5m"
参数说明:
FRP_SERVER_ADDR:frps 公网ip地址
FRP_SERVER_PORT:frps 端口
FRP_SERVER_TOKEN:frps token
REMOTE_PORT:frps 暴露的端口,需要提前预留,本示例为 8080
LOCAL_IP:内网 app 地址
LOCAL_PORT:内网 app 端口
启动服务
docker-compose up -d
$ docker exec -it frpc sh
$ app add python3
$ python3 -m http.server 8080
- 访问
http://<frps-public-ip>:8080
类似工具