docker-compose部署frp server

文章目录

      • 1. 初始化配置文件
      • 2. docker-compose.yaml
      • 3. 部署
      • 4. 卸载
      • 5. web-nginx域名去除端口
      • 6. frpc客户端使用

1. 初始化配置文件

mkdir -p /root/i/docker-compose/frps && cd /root/i/docker-compose/frps

cat < frps.ini
[common]
bind_port = 7000
vhost_http_port = 8080
vhost_https_port = 8081
dashboard_addr = 0.0.0.0
dashboard_port = 7500
dashboard_user = admin
dashboard_pwd = www19930327
EOF

2. docker-compose.yaml

cat < /root/i/docker-compose/frps/docker-compose.yaml
version: '3'
services:
  frps:
    restart: always
    image: snowdreamtech/frps
    container_name: frps
    volumes:
      - /root/i/docker-compose/frps/frps.ini:/etc/frp/frps.ini
    ports:
      - 7000:7000
      - 7500:7500
      - 8080:8080
      - 8081:8081

  frpc-web-nginx:
    restart: always
    image: nginx:1.19.3
    container_name: frpc-web-nginx
    volumes:
      - /root/i/docker-compose/frps/nginx-conf:/etc/nginx/conf.d
    ports:
      - 80:80
EOF

3. 部署

docker-compose -f /root/i/docker-compose/frps/docker-compose.yaml up -d

4. 卸载

docker-compose -f /root/i/docker-compose/frps/docker-compose.yaml down

5. web-nginx域名去除端口

因为80端口被使用,所以http使用了8080端口,使用域名时还需要在后面加上8080端口才能内网穿透,所以使用nginx监听端口,直接使用域名内网穿透

portal-dev.wanfei.wang

cat < /root/i/docker-compose/frps/nginx-conf/portal-dev.wanfei.wang.conf
server {
    listen  80;
    server_name  portal-dev.wanfei.wang;
    
    location / {
        proxy_set_header  Host  \$http_host;
        proxy_set_header  X-Real-IP  \$remote_addr;
        proxy_set_header  X-Forwarded-For \$proxy_add_x_forwarded_for;
        proxy_pass  http://frps:8080/;
    }
}
EOF

重启frpc-web-nginx服务

docker-compose -f /root/i/docker-compose/frps/docker-compose.yaml restart frpc-web-nginx

6. frpc客户端使用

参考 https://blog.csdn.net/qq_38983728/article/details/103595506

你可能感兴趣的:(docker,容器,frp)