├── .github └── workflows │ └── docker-build-release.yml ├── .gitignore ├── Dockerfile ├── README.md ├── frps.service ├── frps.toml ├── frps_linux_install.sh └── frps_linux_uninstall.sh /.github/workflows/docker-build-release.yml: -------------------------------------------------------------------------------- 1 | name: "docker build release" 2 | 3 | on: 4 | push: 5 | workflow_dispatch: 6 | 7 | env: 8 | PROJECT: frps 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Checkout 15 | uses: actions/checkout@v2.3.5 16 | 17 | - name: Set tag 18 | id: tag 19 | run: | 20 | if [[ -n $(cat Dockerfile | awk '{if($1~"ENV" && $2=="VERSION")print $3}') ]]; then 21 | VERSION=$(cat Dockerfile | awk '{if($1~"ENV" && $2=="VERSION")print $3}') 22 | echo "tag=$VERSION" >> $GITHUB_ENV 23 | else 24 | echo "tag=$(date +%Y)-$(date +%m)-$(date +%d)" >> $GITHUB_ENV 25 | fi 26 | 27 | - name: Set up QEMU 28 | uses: docker/setup-qemu-action@v1 29 | 30 | - name: Set up Docker Buildx 31 | uses: docker/setup-buildx-action@v1 32 | 33 | - name: Login Docker Hub 34 | uses: docker/login-action@v1 35 | with: 36 | username: ${{ secrets.DOCKER_USERNAME }} 37 | password: ${{ secrets.DOCKER_PASSWORD }} 38 | 39 | - name: Build and push to docker hub 40 | uses: docker/build-push-action@v2 41 | with: 42 | context: . 43 | platforms: linux/amd64,linux/arm64 44 | push: true 45 | tags: | 46 | ${{ secrets.DOCKER_USERNAME }}/${{ env.PROJECT }}:latest 47 | ${{ secrets.DOCKER_USERNAME }}/${{ env.PROJECT }}:${{ env.tag }} 48 | 49 | - name: Sync README.md to Docker Hub 50 | uses: ms-jpq/sync-dockerhub-readme@v1 51 | with: 52 | username: ${{ secrets.DOCKER_USERNAME }} 53 | password: ${{ secrets.DOCKER_PASSWORD }} 54 | repository: ${{ secrets.DOCKER_USERNAME }}/${{ env.PROJECT }} 55 | readme: "./README.md" 56 | 57 | - name: Login harbor 58 | uses: docker/login-action@v1 59 | with: 60 | registry: ${{ secrets.HARBOR_REGISTRY }} 61 | username: ${{ secrets.HARBOR_USERNAME }} 62 | password: ${{ secrets.HARBOR_PASSWORD }} 63 | 64 | - name: Build and push to harbor 65 | uses: docker/build-push-action@v2 66 | with: 67 | context: . 68 | platforms: linux/amd64,linux/arm64 69 | push: true 70 | tags: | 71 | ${{ secrets.HARBOR_REGISTRY }}/${{ secrets.HARBOR_USERNAME }}/${{ env.PROJECT }}:latest 72 | ${{ secrets.HARBOR_REGISTRY }}/${{ secrets.HARBOR_USERNAME }}/${{ env.PROJECT }}:${{ env.tag }} 73 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.8 2 | LABEL maintainer="Stille " 3 | 4 | ENV VERSION 0.62.1 5 | ENV TZ=Asia/Shanghai 6 | WORKDIR / 7 | 8 | RUN apk add --no-cache tzdata \ 9 | && ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime \ 10 | && echo ${TZ} > /etc/timezone 11 | 12 | RUN if [ "$(uname -m)" = "x86_64" ]; then export PLATFORM=amd64 ; \ 13 | elif [ "$(uname -m)" = "aarch64" ]; then export PLATFORM=arm64 ; \ 14 | elif [ "$(uname -m)" = "armv7" ]; then export PLATFORM=arm ; \ 15 | elif [ "$(uname -m)" = "armv7l" ]; then export PLATFORM=arm ; \ 16 | elif [ "$(uname -m)" = "armhf" ]; then export PLATFORM=arm ; fi \ 17 | && wget --no-check-certificate https://github.com/fatedier/frp/releases/download/v${VERSION}/frp_${VERSION}_linux_${PLATFORM}.tar.gz \ 18 | && tar xzf frp_${VERSION}_linux_${PLATFORM}.tar.gz \ 19 | && cd frp_${VERSION}_linux_${PLATFORM} \ 20 | && mkdir /frp \ 21 | && mv frps frps.toml /frp \ 22 | && cd .. \ 23 | && rm -rf *.tar.gz frp_${VERSION}_linux_${PLATFORM} 24 | 25 | VOLUME /frp 26 | 27 | CMD /frp/frps -c /frp/frps.toml 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # frps 2 | ## 项目简介 3 | 基于 [fatedier/frp](https://github.com/fatedier/frp) 原版 frp 内网穿透服务端 frps 的一键安装卸载脚本和 docker 镜像.支持 Linux 服务器和 docker 等多种环境安装部署. 4 | 5 | - GitHub [stilleshan/frps](https://github.com/stilleshan/frps) 6 | - Docker [stilleshan/frps](https://hub.docker.com/r/stilleshan/frps) 7 | > *docker image support for X86 and ARM* 8 | 9 | ## 更新 10 | - **2024-02-25** 更新到新版本,支持 toml 配置文件. 11 | - **2021-05-31** 更新国内镜像方便使用 12 | - **2021-05-31** 更新 Linux 一键安装脚本同时支持 X86 和 ARM 13 | - **2021-05-29** 更新从`0.36.2`版本起 docker 镜像同时支持 X86 和 ARM 14 | 15 | ## 使用 16 | 由于 frps 服务端需要配置参数,本脚本为原版 frps.toml ,安装完毕后请自行编辑 frps.toml 配置端口,密码等相关参数并重启服务.同时你也可以 fork 本仓库后自行修改 frps.toml ,在进行一键安装也非常方便.后期也可自行配置 frps.toml 和调整 frps 的版本. 17 | 18 | ### 一键脚本(先执行脚本,在自行修改 frps.toml 文件.) 19 | 安装 20 | ```shell 21 | wget https://raw.githubusercontent.com/stilleshan/frps/master/frps_linux_install.sh && chmod +x frps_linux_install.sh && ./frps_linux_install.sh 22 | # 以下为国内镜像 23 | wget https://github.ioiox.com/stilleshan/frps/raw/branch/master/frps_linux_install.sh && chmod +x frps_linux_install.sh && ./frps_linux_install.sh 24 | ``` 25 | 26 | 使用 27 | ```shell 28 | vi /usr/local/frp/frps.toml 29 | # 修改 frps.toml 配置 30 | sudo systemctl restart frps 31 | # 重启 frps 服务即可生效 32 | ``` 33 | 34 | 卸载 35 | ```shell 36 | wget https://raw.githubusercontent.com/stilleshan/frps/master/frps_linux_uninstall.sh && chmod +x frps_linux_uninstall.sh && ./frps_linux_uninstall.sh 37 | # 以下为国内镜像 38 | wget https://github.ioiox.com/stilleshan/frps/raw/branch/master/frps_linux_uninstall.sh && chmod +x frps_linux_uninstall.sh && ./frps_linux_uninstall.sh 39 | ``` 40 | 41 | ### 自定义一键脚本(先 fork 本仓库,在自行修改 frps.toml 文件后执行脚本.) 42 | - 首先 fork 本仓库 43 | - 配置 frps.toml 44 | - 修改 frps_linux_install.sh 脚本 45 | - 修改脚本链接 46 | - Push 仓库到 GitHub 47 | 48 | #### 修改 frps_linux_install.sh 脚本 49 | `FRP_VERSION=0.62.1` 可根据原版项目更新自行修改为最新版本. 50 | `REPO=stilleshan/frps` 由于 **fork** 到你自己的仓库,需修改`stilleshan`为你的 GitHub 账号ID. 51 | 52 | #### 执行一键脚本 53 | 修改以下脚本链接中的`stilleshan`为你的 GitHub 账号 ID 后,执行即可. 54 | ```shell 55 | wget https://raw.githubusercontent.com/stilleshan/frps/master/frps_linux_install.sh && chmod +x frps_linux_install.sh && ./frps_linux_install.sh 56 | ``` 57 | #### 卸载脚本 58 | frps_linux_uninstall.sh 卸载脚本为通用脚本,可直接执行,也可同上方式修改链接后执行. 59 | ```shell 60 | wget https://raw.githubusercontent.com/stilleshan/frps/master/frps_linux_uninstall.sh && chmod +x frps_linux_uninstall.sh && ./frps_linux_uninstall.sh 61 | ``` 62 | 63 | ### frps相关命令 64 | ```shell 65 | sudo systemctl start frps 66 | # 启动服务 67 | sudo systemctl enable frps 68 | # 开机自启 69 | sudo systemctl status frps 70 | # 状态查询 71 | sudo systemctl restart frps 72 | # 重启服务 73 | sudo systemctl stop frps 74 | # 停止服务 75 | ``` 76 | 77 | ### docker 部署 78 | 为避免因 **frps.toml** 文件的挂载,格式或者配置的错误导致容器无法正常运行并循环重启.请确保先配置好 **frps.toml** 后在执行启动. 79 | 80 | 先 **git clone** 本仓库,并正确配置 **frps.toml** 文件. 81 | ```shell 82 | git clone https://github.com/stilleshan/frps 83 | # git clone 本仓库 84 | git clone https://github.ioiox.com/stilleshan/frps 85 | # 国内镜像 86 | vi /root/frps/frps.toml 87 | # 配置 frps.toml 文件 88 | ``` 89 | 启动容器 90 | ```shell 91 | docker run -d --name=frps --restart=always \ 92 | --network host \ 93 | -v /root/frps/frps.toml:/frp/frps.toml \ 94 | stilleshan/frps 95 | ``` 96 | > 以上命令 -v 挂载的目录是以 git clone 本仓库为例,也可以在任意位置手动创建 frps.toml 文件,并修改命令中的挂载路径. 97 | 98 | 服务运行中修改 **frps.toml** 配置后需重启 **frps** 服务. 99 | ```shell 100 | vi /root/frps/frps.toml 101 | # 修改 frps.toml 配置 102 | docker restart frps 103 | # 重启 frps 容器即可生效 104 | ``` 105 | 106 | ## 链接 107 | - Blog [www.ioiox.com](https://www.ioiox.com) 108 | - GitHub [stilleshan/frps](https://github.com/stilleshan/frps) 109 | - Docker Hub [stilleshan/frps](https://hub.docker.com/r/stilleshan/frps) 110 | - Docker [docker.ioiox.com](https://docker.ioiox.com) 111 | - 原版frp项目 [fatedier/frp](https://github.com/fatedier/frp) 112 | - [CentOS 7 安装配置frp内网穿透服务器端教程](https://www.ioiox.com/archives/5.html) -------------------------------------------------------------------------------- /frps.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Frp Server Service 3 | After=network.target syslog.target 4 | Wants=network.target 5 | 6 | [Service] 7 | Type=simple 8 | Restart=on-failure 9 | RestartSec=5s 10 | ExecStart=/usr/local/frp/frps -c /usr/local/frp/frps.toml 11 | 12 | [Install] 13 | WantedBy=multi-user.target -------------------------------------------------------------------------------- /frps.toml: -------------------------------------------------------------------------------- 1 | bindAddr = "0.0.0.0" 2 | bindPort = 7000 3 | #kcpBindPort = 7000 4 | quicBindPort = 7000 5 | 6 | vhostHTTPPort = 80 7 | vhostHTTPSPort = 443 8 | 9 | transport.maxPoolCount = 2000 10 | transport.tcpMux = true 11 | transport.tcpMuxKeepaliveInterval = 60 12 | transport.tcpKeepalive = 7200 13 | transport.tls.force = false 14 | 15 | webServer.addr = "0.0.0.0" 16 | webServer.port = 7500 17 | webServer.user = "admin" 18 | webServer.password = "admin" 19 | webServer.pprofEnable = false 20 | 21 | log.to = "./frps.log" 22 | log.level = "info" 23 | log.maxDays = 3 24 | log.disablePrintColor = false 25 | 26 | auth.method = "token" 27 | auth.token = "12345678" 28 | 29 | allowPorts = [ 30 | { start = 10001, end = 50000 } 31 | ] 32 | 33 | maxPortsPerClient = 8 34 | udpPacketSize = 1500 35 | natholeAnalysisDataReserveHours = 168 36 | -------------------------------------------------------------------------------- /frps_linux_install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin 3 | export PATH 4 | 5 | # fonts color 6 | Green="\033[32m" 7 | Red="\033[31m" 8 | Yellow="\033[33m" 9 | GreenBG="\033[42;37m" 10 | RedBG="\033[41;37m" 11 | Font="\033[0m" 12 | # fonts color 13 | 14 | # variable 15 | FRP_VERSION=0.62.1 16 | REPO=stilleshan/frps 17 | WORK_PATH=$(dirname $(readlink -f $0)) 18 | FRP_NAME=frps 19 | FRP_PATH=/usr/local/frp 20 | PROXY_URL="https://ghfast.top/" 21 | 22 | # check frps 23 | if [ -f "/usr/local/frp/${FRP_NAME}" ] || [ -f "/usr/local/frp/${FRP_NAME}.toml" ] || [ -f "/lib/systemd/system/${FRP_NAME}.service" ];then 24 | echo -e "${Green}=========================================================================${Font}" 25 | echo -e "${RedBG}当前已退出脚本.${Font}" 26 | echo -e "${Green}检查到服务器已安装${Font} ${Red}${FRP_NAME}${Font}" 27 | echo -e "${Green}请手动确认和删除${Font} ${Red}/usr/local/frp/${Font} ${Green}目录下的${Font} ${Red}${FRP_NAME}${Font} ${Green}和${Font} ${Red}/${FRP_NAME}.toml${Font} ${Green}文件以及${Font} ${Red}/lib/systemd/system/${FRP_NAME}.service${Font} ${Green}文件,再次执行本脚本.${Font}" 28 | echo -e "${Green}参考命令如下:${Font}" 29 | echo -e "${Red}rm -rf /usr/local/frp/${FRP_NAME}${Font}" 30 | echo -e "${Red}rm -rf /usr/local/frp/${FRP_NAME}.toml${Font}" 31 | echo -e "${Red}rm -rf /lib/systemd/system/${FRP_NAME}.service${Font}" 32 | echo -e "${Green}=========================================================================${Font}" 33 | exit 2 34 | fi 35 | 36 | while ! test -z "$(ps -A | grep -w ${FRP_NAME})"; do 37 | FRPSPID=$(ps -A | grep -w ${FRP_NAME} | awk 'NR==1 {print $1}') 38 | kill -9 $FRPSPID 39 | done 40 | 41 | # check pkg 42 | if type apt-get >/dev/null 2>&1 ; then 43 | if ! type wget >/dev/null 2>&1 ; then 44 | apt-get install wget -y 45 | fi 46 | if ! type curl >/dev/null 2>&1 ; then 47 | apt-get install curl -y 48 | fi 49 | fi 50 | 51 | if type yum >/dev/null 2>&1 ; then 52 | if ! type wget >/dev/null 2>&1 ; then 53 | yum install wget -y 54 | fi 55 | if ! type curl >/dev/null 2>&1 ; then 56 | yum install curl -y 57 | fi 58 | fi 59 | 60 | # check network 61 | GOOGLE_HTTP_CODE=$(curl -o /dev/null --connect-timeout 5 --max-time 8 -s --head -w "%{http_code}" "https://www.google.com") 62 | PROXY_HTTP_CODE=$(curl -o /dev/null --connect-timeout 5 --max-time 8 -s --head -w "%{http_code}" "${PROXY_URL}") 63 | 64 | # check arch 65 | if [ $(uname -m) = "x86_64" ]; then 66 | PLATFORM=amd64 67 | fi 68 | 69 | if [ $(uname -m) = "aarch64" ]; then 70 | PLATFORM=arm64 71 | fi 72 | 73 | FILE_NAME=frp_${FRP_VERSION}_linux_${PLATFORM} 74 | 75 | if [ ! -f "${WORK_PATH}/${FILE_NAME}.tar.gz" ]; then 76 | if [ $GOOGLE_HTTP_CODE == "200" ]; then 77 | wget -P ${WORK_PATH} https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/${FILE_NAME}.tar.gz -O ${FILE_NAME}.tar.gz 78 | wget -P ${WORK_PATH} https://raw.githubusercontent.com/${REPO}/master/${FRP_NAME}.toml -O ${FRP_NAME}.toml 79 | else 80 | if [ $PROXY_HTTP_CODE == "200" ]; then 81 | wget -P ${WORK_PATH} ${PROXY_URL}https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/${FILE_NAME}.tar.gz -O ${FILE_NAME}.tar.gz 82 | wget -P ${WORK_PATH} ${PROXY_URL}https://raw.githubusercontent.com/${REPO}/master/${FRP_NAME}.toml -O ${FRP_NAME}.toml 83 | else 84 | echo -e "${Red}检测 GitHub Proxy 代理失效 开始使用官方地址下载${Font}" 85 | wget -P ${WORK_PATH} https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/${FILE_NAME}.tar.gz -O ${FILE_NAME}.tar.gz 86 | wget -P ${WORK_PATH} https://raw.githubusercontent.com/${REPO}/master/${FRP_NAME}.toml -O ${FRP_NAME}.toml 87 | fi 88 | fi 89 | else 90 | echo -e "${Green}文件 ${FILE_NAME}.tar.gz 已存在, 跳过下载.${Font}" 91 | fi 92 | 93 | tar -zxvf ${FILE_NAME}.tar.gz 94 | mkdir -p ${FRP_PATH} 95 | mv ${FILE_NAME}/${FRP_NAME} ${FRP_PATH} 96 | mv ${FRP_NAME}.toml ${FRP_PATH} 97 | 98 | # 配置 frps.service 99 | cat >/lib/systemd/system/frps.service <<'EOF' 100 | [Unit] 101 | Description=Frp Server Service 102 | After=network.target syslog.target 103 | Wants=network.target 104 | 105 | [Service] 106 | Type=simple 107 | Restart=on-failure 108 | RestartSec=5s 109 | ExecStart=/usr/local/frp/frps -c /usr/local/frp/frps.toml 110 | 111 | [Install] 112 | WantedBy=multi-user.target 113 | 114 | EOF 115 | 116 | systemctl daemon-reload 117 | sudo systemctl start ${FRP_NAME} 118 | sudo systemctl enable ${FRP_NAME} 119 | 120 | # clean 121 | rm -rf ${WORK_PATH}/${FILE_NAME}.tar.gz ${WORK_PATH}/${FILE_NAME} ${FRP_NAME}_linux_install.sh 122 | 123 | echo -e "${Green}====================================================================${Font}" 124 | echo -e "${Green}安装成功,请先修改 ${FRP_NAME}.toml 文件,确保格式及配置正确无误!${Font}" 125 | echo -e "${Red}vi /usr/local/frp/${FRP_NAME}.toml${Font}" 126 | echo -e "${Green}修改完毕后执行以下命令重启服务:${Font}" 127 | echo -e "${Red}sudo systemctl restart ${FRP_NAME}${Font}" 128 | echo -e "${Green}====================================================================${Font}" 129 | -------------------------------------------------------------------------------- /frps_linux_uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin 3 | export PATH 4 | 5 | # fonts color 6 | Green="\033[32m" 7 | Red="\033[31m" 8 | Yellow="\033[33m" 9 | GreenBG="\033[42;37m" 10 | RedBG="\033[41;37m" 11 | Font="\033[0m" 12 | # fonts color 13 | 14 | # variable 15 | WORK_PATH=$(dirname $(readlink -f $0)) 16 | FRP_NAME=frps 17 | FRP_VERSION=0.62.1 18 | FRP_PATH=/usr/local/frp 19 | 20 | # 停止frpc 21 | sudo systemctl stop ${FRP_NAME} 22 | sudo systemctl disable ${FRP_NAME} 23 | # 删除frpc 24 | rm -rf ${FRP_PATH} 25 | # 删除frpc.service 26 | rm -rf /lib/systemd/system/${FRP_NAME}.service 27 | sudo systemctl daemon-reload 28 | # 删除本文件 29 | rm -rf ${FRP_NAME}_linux_uninstall.sh 30 | 31 | echo -e "${Green}============================${Font}" 32 | echo -e "${Green}卸载成功,相关文件已清理完毕!${Font}" 33 | echo -e "${Green}============================${Font}" 34 | --------------------------------------------------------------------------------