├── .github └── workflows │ └── docker-build-release.yml ├── .gitignore ├── Dockerfile ├── README.md ├── frpc.service ├── frpc.toml ├── frpc_linux_install.sh ├── frpc_linux_uninstall.sh ├── frpc_synology_install.sh └── frpc_synology_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: frpc 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,linux/arm/v7 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,linux/arm/v7 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 frpc frpc.toml /frp \ 22 | && cd .. \ 23 | && rm -rf *.tar.gz frp_${VERSION}_linux_${PLATFORM} 24 | 25 | VOLUME /frp 26 | 27 | CMD /frp/frpc -c /frp/frpc.toml 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # frpc 2 | ## 项目简介 3 | 基于 [fatedier/frp](https://github.com/fatedier/frp) 原版 frp 内网穿透客户端 frpc 的一键安装卸载脚本和 docker 镜像.支持群晖NAS,Linux 服务器和 docker 等多种环境安装部署. 4 | 5 | - GitHub [stilleshan/frpc](https://github.com/stilleshan/frpc) 6 | - Docker [stilleshan/frpc](https://hub.docker.com/r/stilleshan/frpc) 7 | > *docker image support for X86 and ARM* 8 | 9 | ## 更新 10 | - **2024-03-03** 更新到新版本,支持 toml 配置文件. 11 | - **2021-05-31** 更新国内镜像方便使用 12 | - **2021-05-31** 目前 X86 群晖 DMS 7.0 可直接使用 Linux 版本脚本,已实测.由于没有 ARM 版可尝试,请自行尝试. 13 | - **2021-05-31** 更新 Linux 一键安装脚本同时支持 X86 和 ARM 14 | - **2021-05-29** 更新从`0.36.2`版本起 docker 镜像同时支持 X86 和 ARM 15 | 16 | ## 使用 17 | 以下分为四种部署方法,请根据实际情况自行选择: 18 | 19 | 1. 群晖 NAS docker 安装 **[支持 docker 的群晖机型首选]** 20 | 2. 群晖 NAS 一键脚本安装 **[不支持 docker 的群晖机型]** 21 | 3. Linux 服务器 一键脚本安装 **[内网 Linux 服务器或虚拟机]** 22 | 4. Linux 服务器 docker 安装 **[内网 Linux 服务器或虚拟机]** 23 | 24 | --- 25 | 26 | ### 1. 群晖 NAS docker 安装 **[支持 docker 的群晖机型首选]** 27 | [详情点击查看教程](https://www.ioiox.com/archives/26.html) 28 | 29 | ### 2. 群晖 NAS 一键脚本安装 **[不支持 docker 的群晖机型]** 30 | [详情点击查看教程](https://www.ioiox.com/archives/6.html) 31 | 32 | ### 3. Linux 服务器 一键脚本安装 33 | > *本脚本目前同时支持 Linux X86 和 ARM 架构* 34 | 35 | 安装 36 | ```shell 37 | wget https://raw.githubusercontent.com/stilleshan/frpc/master/frpc_linux_install.sh && chmod +x frpc_linux_install.sh && ./frpc_linux_install.sh 38 | # 以下为国内镜像 39 | wget https://ghfast.top/https://raw.githubusercontent.com/stilleshan/frpc/master/frpc_linux_install.sh && chmod +x frpc_linux_install.sh && ./frpc_linux_install.sh 40 | ``` 41 | 42 | 使用 43 | ```shell 44 | vi /usr/local/frp/frpc.toml 45 | # 修改 frpc.toml 配置 46 | sudo systemctl restart frpc 47 | # 重启 frpc 服务即可生效 48 | ``` 49 | 50 | 卸载 51 | ```shell 52 | wget https://raw.githubusercontent.com/stilleshan/frpc/master/frpc_linux_uninstall.sh && chmod +x frpc_linux_uninstall.sh && ./frpc_linux_uninstall.sh 53 | # 以下为国内镜像 54 | wget https://ghfast.top/https://raw.githubusercontent.com/stilleshan/frpc/master/frpc_linux_uninstall.sh && chmod +x frpc_linux_uninstall.sh && ./frpc_linux_uninstall.sh 55 | ``` 56 | 57 | ### 4. Linux 服务器 docker 安装 58 | 为避免因 **frpc.toml** 文件的挂载,格式或者配置的错误导致容器无法正常运行并循环重启.请确保先配置好 **frpc.toml** 后在运行启动. 59 | 60 | **git clone** 本仓库,并正确配置 **frpc.toml** 文件. 61 | ```shell 62 | git clone https://github.com/stilleshan/frpc 63 | # git clone 本仓库镜像 64 | git clone https://ghfast.top/https://github.com/stilleshan/frpc 65 | # 国内镜像 66 | vi /root/frpc/frpc.toml 67 | # 配置 frpc.toml 文件 68 | ``` 69 | 70 | 执行以下命令启动服务 71 | ```shell 72 | docker run -d --name=frpc --restart=always -v /root/frpc/frpc.toml:/frp/frpc.toml stilleshan/frpc 73 | ``` 74 | > 以上命令 -v 挂载的目录是以 git clone 本仓库为例,也可以在任意位置手动创建 frpc.toml 文件,并修改命令中的挂载路径. 75 | 76 | 服务运行中修改 **frpc.toml** 配置后需重启 **frpc** 服务. 77 | ```shell 78 | vi /root/frp/frpc.toml 79 | # 修改 frpc.toml 配置 80 | docker restart frpc 81 | # 重启 frpc 容器即可生效 82 | ``` 83 | 84 | ## 链接 85 | - Blog [www.ioiox.com](https://www.ioiox.com) 86 | - GitHub [stilleshan/frpc](https://github.com/stilleshan/frpc) 87 | - Docker Hub [stilleshan/frpc](https://hub.docker.com/r/stilleshan/frpc) 88 | - Docker [docker.ioiox.com](https://docker.ioiox.com) 89 | - 原版frp项目 [fatedier/frp](https://github.com/fatedier/frp) 90 | - [群晖NAS使用Docker安装配置frpc内网穿透教程](https://www.ioiox.com/archives/26.html) 91 | - [群晖NAS安装配置免费frp内网穿透教程](https://www.ioiox.com/archives/6.html) 92 | - [新手入门 - 详解 frp 内网穿透 frpc.toml 配置](https://www.ioiox.com/archives/79.html) -------------------------------------------------------------------------------- /frpc.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/frpc -c /usr/local/frp/frpc.ini 11 | 12 | [Install] 13 | WantedBy=multi-user.target -------------------------------------------------------------------------------- /frpc.toml: -------------------------------------------------------------------------------- 1 | serverAddr = "frp.freefrp.net" 2 | serverPort = 7000 3 | auth.method = "token" 4 | auth.token = "freefrp.net" 5 | 6 | [[proxies]] 7 | name = "web1_xxxxx" 8 | type = "http" 9 | localIP = "192.168.1.2" 10 | localPort = 5000 11 | customDomains = ["nas.yourdomain.com"] 12 | 13 | [[proxies]] 14 | name = "web2_xxxxx" 15 | type = "https" 16 | localIP = "192.168.1.2" 17 | localPort = 5001 18 | customDomains = ["nas.yourdomain.com"] 19 | 20 | [[proxies]] 21 | name = "tcp1_xxxxx" 22 | type = "tcp" 23 | localIP = "192.168.1.3" 24 | localPort = 22 25 | remotePort = 22222 26 | -------------------------------------------------------------------------------- /frpc_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 | WORK_PATH=$(dirname $(readlink -f $0)) 16 | FRP_NAME=frpc 17 | FRP_VERSION=0.62.1 18 | FRP_PATH=/usr/local/frp 19 | PROXY_URL="https://ghfast.top/" 20 | 21 | # check frpc 22 | if [ -f "/usr/local/frp/${FRP_NAME}" ] || [ -f "/usr/local/frp/${FRP_NAME}.toml" ] || [ -f "/lib/systemd/system/${FRP_NAME}.service" ];then 23 | echo -e "${Green}=========================================================================${Font}" 24 | echo -e "${RedBG}当前已退出脚本.${Font}" 25 | echo -e "${Green}检查到服务器已安装${Font} ${Red}${FRP_NAME}${Font}" 26 | 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}" 27 | echo -e "${Green}参考命令如下:${Font}" 28 | echo -e "${Red}rm -rf /usr/local/frp/${FRP_NAME}${Font}" 29 | echo -e "${Red}rm -rf /usr/local/frp/${FRP_NAME}.toml${Font}" 30 | echo -e "${Red}rm -rf /lib/systemd/system/${FRP_NAME}.service${Font}" 31 | echo -e "${Green}=========================================================================${Font}" 32 | exit 0 33 | fi 34 | 35 | while ! test -z "$(ps -A | grep -w ${FRP_NAME})"; do 36 | FRPCPID=$(ps -A | grep -w ${FRP_NAME} | awk 'NR==1 {print $1}') 37 | kill -9 $FRPCPID 38 | done 39 | 40 | # check pkg 41 | if type apt-get >/dev/null 2>&1 ; then 42 | if ! type wget >/dev/null 2>&1 ; then 43 | apt-get install wget -y 44 | fi 45 | if ! type curl >/dev/null 2>&1 ; then 46 | apt-get install curl -y 47 | fi 48 | fi 49 | 50 | if type yum >/dev/null 2>&1 ; then 51 | if ! type wget >/dev/null 2>&1 ; then 52 | yum install wget -y 53 | fi 54 | if ! type curl >/dev/null 2>&1 ; then 55 | yum install curl -y 56 | fi 57 | fi 58 | 59 | # check network 60 | GOOGLE_HTTP_CODE=$(curl -o /dev/null --connect-timeout 5 --max-time 8 -s --head -w "%{http_code}" "https://www.google.com") 61 | PROXY_HTTP_CODE=$(curl -o /dev/null --connect-timeout 5 --max-time 8 -s --head -w "%{http_code}" "${PROXY_URL}") 62 | 63 | # check arch 64 | if [ $(uname -m) = "x86_64" ]; then 65 | PLATFORM=amd64 66 | elif [ $(uname -m) = "aarch64" ]; then 67 | PLATFORM=arm64 68 | elif [ $(uname -m) = "armv7" ]; then 69 | PLATFORM=arm 70 | elif [ $(uname -m) = "armv7l" ]; then 71 | PLATFORM=arm 72 | elif [ $(uname -m) = "armhf" ]; then 73 | PLATFORM=arm 74 | fi 75 | 76 | FILE_NAME=frp_${FRP_VERSION}_linux_${PLATFORM} 77 | 78 | # download 79 | if [ $GOOGLE_HTTP_CODE == "200" ]; then 80 | wget -P ${WORK_PATH} https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/${FILE_NAME}.tar.gz -O ${FILE_NAME}.tar.gz 81 | else 82 | if [ $PROXY_HTTP_CODE == "200" ]; then 83 | 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 84 | else 85 | echo -e "${Red}检测 GitHub Proxy 代理失效 开始使用官方地址下载${Font}" 86 | wget -P ${WORK_PATH} https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/${FILE_NAME}.tar.gz -O ${FILE_NAME}.tar.gz 87 | fi 88 | fi 89 | tar -zxvf ${FILE_NAME}.tar.gz 90 | 91 | mkdir -p ${FRP_PATH} 92 | mv ${FILE_NAME}/${FRP_NAME} ${FRP_PATH} 93 | 94 | # configure frpc.toml 95 | RADOM_NAME=$(cat /dev/urandom | head -n 10 | md5sum | head -c 8) 96 | cat >${FRP_PATH}/${FRP_NAME}.toml</lib/systemd/system/${FRP_NAME}.service <${FRP_PATH}/${FRP_NAME}.toml </dev/null 2>&1 &${Font}" 108 | echo -e "${Green}=======================================================================${Font}" 109 | -------------------------------------------------------------------------------- /frpc_synology_uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # fonts color 4 | Green="\033[32m" 5 | Red="\033[31m" 6 | Yellow="\033[33m" 7 | GreenBG="\033[42;37m" 8 | RedBG="\033[41;37m" 9 | Font="\033[0m" 10 | # fonts color 11 | 12 | while ! test -z "$(ps -A | grep -w ${FRP_NAME})"; do 13 | FRPCPID=$(ps -A | grep -w ${FRP_NAME} | awk 'NR==1 {print $1}') 14 | kill -9 $FRPCPID 15 | done 16 | 17 | # 删除frp 18 | rm -rf /usr/local/frp && \ 19 | # 删除本文件 20 | rm -rf frpc_synology_uninstall.sh 21 | 22 | echo -e "${Green}============================${Font}" 23 | echo -e "${Green}卸载成功,相关文件已清理完毕!${Font}" 24 | echo -e "${Green}============================${Font}" 25 | --------------------------------------------------------------------------------