├── demo ├── frpc.ini ├── frps.ini ├── frps-docker-compose.yml └── frpc-docker-compose.yml ├── LICENSE ├── Dockerfile ├── docker-entrypoint.sh └── README.md /demo/frpc.ini: -------------------------------------------------------------------------------- 1 | [common] 2 | server_addr = ${FRP_SERVER_ADDR} 3 | server_port = 7000 4 | protocol = kcp 5 | privilege_token = ${FRP_PRIVILEGE_TOKEN} 6 | tcp_mux = true 7 | pool_count = 5 8 | 9 | [http] 10 | type = tcp 11 | local_ip = web_server 12 | local_port = 80 13 | remote_port = 80 14 | 15 | [https] 16 | type = tcp 17 | local_ip = web_server 18 | local_port = 443 19 | remote_port = 443 20 | -------------------------------------------------------------------------------- /demo/frps.ini: -------------------------------------------------------------------------------- 1 | [common] 2 | bind_addr = ${FRP_SERVER_ADDR} 3 | bind_port = 7000 4 | kcp_bind_port = 7000 5 | bind_udp_port = 7001 6 | tcp_mux = true 7 | max_pool_count = 5 8 | privilege_token = ${FRP_PRIVILEGE_TOKEN} 9 | privilege_allow_ports = 23-65535 10 | 11 | dashboard_addr = ${FRP_SERVER_ADDR} 12 | dashboard_port = 7500 13 | dashboard_user = admin 14 | dashboard_pwd = ${FRP_DASHBOARD_PWD} 15 | -------------------------------------------------------------------------------- /demo/frps-docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | frp_server: 4 | image: geektr/frp 5 | environment: 6 | - FRP_SERVER_ADDR=your_server_address 7 | - FRP_PRIVILEGE_TOKEN=your_serect_frp_privilege_token 8 | - FRP_DASHBOARD_PWD=your_frp_dashboard_password 9 | restart: always 10 | network_mode: "host" 11 | volumes: 12 | - ./frps.ini:/etc/frp/frps.ini:ro 13 | -------------------------------------------------------------------------------- /demo/frpc-docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | web_server: 4 | image: nginx 5 | container_name: web_server 6 | expose: 7 | - "80" 8 | - "443" 9 | frp_client: 10 | image: geektr/frp 11 | environment: 12 | - FRP_SERVER_ADDR=your_server_address 13 | - FRP_PRIVILEGE_TOKEN=your_serect_frp_privilege_token 14 | restart: always 15 | volumes: 16 | - ./frpc.ini:/etc/frp/frpc.ini:ro 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIKU SAIMOE PUBLIC LICENSE 2 | Version 1, January 2018 3 | 4 | Copyright (C) 2018 GeekTR 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | MIKU SAIMOE PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. Say "Miku saimoe". 14 | 1. Then just DO WHAT THE FUCK YOU WANT TO. 15 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.8 2 | 3 | ARG frp_version 4 | 5 | ADD ./docker-entrypoint.sh / 6 | 7 | RUN apk add --virtual .build-dependencies --no-cache openssl 8 | 9 | RUN chmod +x /docker-entrypoint.sh \ 10 | && mkdir -p /etc/frp \ 11 | && cd /tmp \ 12 | && wget -O frp.tar.gz "https://github.com/fatedier/frp/releases/download/v${frp_version}/frp_${frp_version}_linux_amd64.tar.gz" \ 13 | && tar -xzf frp.tar.gz \ 14 | && mv ./frp_${frp_version}_linux_amd64/frpc /usr/local/bin \ 15 | && mv ./frp_${frp_version}_linux_amd64/frps /usr/local/bin \ 16 | && rm -rf /tmp/* 17 | 18 | RUN apk del .build-dependencies 19 | 20 | WORKDIR /etc/frp 21 | 22 | ENTRYPOINT ["/docker-entrypoint.sh"] 23 | -------------------------------------------------------------------------------- /docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ini_files=$(find /etc/frp -name '*.ini') 4 | 5 | for file in $ini_files; do 6 | while read line || [ -n "$line" ]; do 7 | eval echo "$line" 8 | done < "$file">"/tmp/$(basename $file)" 9 | done 10 | 11 | frps_config_source=/etc/frp/frps.ini 12 | frpc_config_source=/etc/frp/frpc.ini 13 | 14 | frps_config=/tmp/frps.ini 15 | frpc_config=/tmp/frpc.ini 16 | 17 | case $FRP_MODE in 18 | frpc|frp-client) 19 | frpc -c $frpc_config 20 | exit 0 21 | ;; 22 | frps|frp-server) 23 | frps -c $frps_config 24 | exit 0 25 | ;; 26 | both) 27 | frpc -c $frpc_config 28 | frps -c $frps_config 29 | exit 0 30 | ;; 31 | *) 32 | if [ ! -f $frpc_config_source ] && [ ! -f $frps_config_source ]; then 33 | echo "Error: config file not found" 34 | exit 1 35 | fi 36 | echo "\$FRP_MODE not set, run as existed config file" 37 | [ -f $frpc_config_source ] && frpc -c $frpc_config 38 | [ -f $frps_config_source ] && frps -c $frps_config 39 | exit 0 40 | ;; 41 | esac 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # frp Docker Image 2 | 3 | ## What is frp 4 | 5 | frp is a fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet. Now, it supports tcp, udp, http and https protocol when requests can be forwarded by domains to backward web services. 6 | 7 | you can visit https://github.com/fatedier/frp for know more 8 | 9 | ## How to use this image 10 | 11 | a config file is necessary for this image, you can [read the doc](https://github.com/fatedier/frp/blob/master/README.md) to know how to write it. 12 | 13 | ### Start a frp server 14 | 15 | ```shell 16 | $ docker run -d --network=host -v /path/to/frps.ini:/etc/frp/frps.ini:ro geektr/frp 17 | ## `--network=host` means the docker container run on host network 18 | ``` 19 | 20 | ### Start a frp client 21 | 22 | ```shell 23 | $ docker run -d --network=host -v /path/to/frpc.ini:/etc/frp/frpc.ini:ro geektr/frp 24 | ## `--network=host` means the docker container run on host network 25 | ``` 26 | 27 | ### Frp mode 28 | 29 | this image can run as both frp server and frp client 30 | what it will run depends on environment variables and config file 31 | 32 | ``` shell 33 | # /somepath/ 34 | # └── config 35 | # ├── frpc.ini 36 | # └── frps.ini 37 | 38 | # first , it depends depend on config file 39 | 40 | $ docker run -d --network=host -v /somepath/config/frps.ini:/etc/frp/frps.ini:ro geektr/frp 41 | # => this command start a frp server 42 | 43 | $ docker run -d --network=host -v /somepath/config/frpc.ini:/etc/frp/frpc.ini:ro geektr/frp 44 | # => this command start a frp client 45 | 46 | $ docker run -d --network=host -v /somepath/config:/etc/frp:ro geektr/frp 47 | # => this command start both server and client 48 | 49 | # you can pass an enviroment variable 'FRP_MODE' to force what it run, 'FRP_MODE' can be set to 'frpc', 'frp-client', 'frps', 'frp-server' and 'both' 50 | $ docker run -d --network=host --env FRP_MODE=frps -v /somepath/config:/etc/frp:ro geektr/frp 51 | # => this command start a frp server 52 | ``` 53 | 54 | ## With Docker Compose 55 | 56 | when this image runs, it will replace all shell like variables to their environment value, this feature may helps in auto deploy and authority control. 57 | 58 | ### An frp server demo 59 | 60 | docker-compose.yml 61 | 62 | ```yml 63 | version: '3' 64 | services: 65 | frp_server: 66 | image: geektr/frp 67 | environment: 68 | - FRP_SERVER_ADDR=${HOST_IP} 69 | - FRP_PRIVILEGE_TOKEN=${FRP_TOKEN} 70 | restart: always 71 | network_mode: "host" 72 | volumes: 73 | - ./frps.ini:/etc/frp/frps.ini:ro 74 | ``` 75 | 76 | frps.ini 77 | 78 | ```ini 79 | [common] 80 | bind_addr = ${FRP_SERVER_ADDR} 81 | bind_port = 7000 82 | bind_udp_port = 7001 83 | privilege_token = ${FRP_PRIVILEGE_TOKEN} 84 | ``` 85 | 86 | .env 87 | 88 | ```env 89 | HOST_IP=xxx.xxx.xxx.xxx 90 | FRP_TOKEN=xxxxxxxxxxxxxxxxxxxx 91 | ``` 92 | 93 | ### An frp client demo 94 | 95 | tips: `local_ip` field support hostname, so you can use `container_name` in `frpc.ini` 96 | 97 | docker-compose.yml 98 | 99 | ```yml 100 | version: '3' 101 | services: 102 | web_server: 103 | image: nginx 104 | container_name: web_server 105 | expose: 106 | - "80" 107 | - "443" 108 | frp_client: 109 | image: geektr/frp 110 | environment: 111 | - FRP_SERVER_ADDR=${HOST_IP} 112 | - FRP_PRIVILEGE_TOKEN=${FRP_TOKEN} 113 | restart: always 114 | volumes: 115 | - ./frpc.ini:/etc/frp/frpc.ini:ro 116 | ``` 117 | 118 | frps.ini 119 | 120 | ```ini 121 | [common] 122 | server_addr = ${FRP_SERVER_ADDR} 123 | server_port = 7000 124 | protocol = kcp 125 | privilege_token = ${FRP_PRIVILEGE_TOKEN} 126 | tcp_mux = true 127 | pool_count = 5 128 | 129 | [http] 130 | type = tcp 131 | local_ip = web_server 132 | local_port = 80 133 | remote_port = 80 134 | 135 | [https] 136 | type = tcp 137 | local_ip = web_server 138 | local_port = 443 139 | remote_port = 443 140 | ``` 141 | 142 | .env 143 | 144 | ```env 145 | HOST_IP=xxx.xxx.xxx.xxx 146 | FRP_TOKEN=xxxxxxxxxxxxxxxxxxxx 147 | ``` 148 | --------------------------------------------------------------------------------