├── docker └── frp │ └── Dockerfile ├── docker-compose.yml ├── LICENSE ├── .gitignore └── README.md /docker/frp/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:latest 2 | 3 | ARG frp_version 4 | 5 | RUN apk add --virtual .build-dependencies --no-cache openssl \ 6 | && mkdir -p /etc/frp \ 7 | && cd /tmp \ 8 | && wget -O frp.tar.gz "https://github.com/fatedier/frp/releases/download/v${frp_version}/frp_${frp_version}_linux_amd64.tar.gz" \ 9 | && tar -xzf frp.tar.gz \ 10 | && mv ./frp_${frp_version}_linux_amd64/frps /usr/local/bin \ 11 | && rm -rf /tmp/* \ 12 | && apk del .build-dependencies 13 | 14 | WORKDIR /etc/frp 15 | 16 | ENTRYPOINT frps $FRP_ARGS 17 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | frp: 4 | build: 5 | context: "." 6 | dockerfile: "docker/frp/Dockerfile" 7 | args: 8 | - "frp_version=${FRP_VERSION:-0.60.0}" 9 | environment: 10 | - "FRP_ARGS=${FRP_ARGS}" 11 | ports: 12 | - "${FRP_PORT:-7000}:7000" 13 | router: 14 | image: itzg/mc-router 15 | depends_on: 16 | - frp 17 | environment: 18 | API_BINDING: ":25564" 19 | ports: 20 | - "25565:25565" 21 | - "127.0.0.1:25564:25564" 22 | command: 23 | - "--mapping=${ROUTER_MAPPING}" 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 sya-ri 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.toptal.com/developers/gitignore/api/windows,macos,linux,dotenv 2 | # Edit at https://www.toptal.com/developers/gitignore?templates=windows,macos,linux,dotenv 3 | 4 | ### dotenv ### 5 | .env 6 | 7 | ### Linux ### 8 | *~ 9 | 10 | # temporary files which can be created if a process still has a handle open of a deleted file 11 | .fuse_hidden* 12 | 13 | # KDE directory preferences 14 | .directory 15 | 16 | # Linux trash folder which might appear on any partition or disk 17 | .Trash-* 18 | 19 | # .nfs files are created when an open file is removed but is still being accessed 20 | .nfs* 21 | 22 | ### macOS ### 23 | # General 24 | .DS_Store 25 | .AppleDouble 26 | .LSOverride 27 | 28 | # Icon must end with two \r 29 | Icon 30 | 31 | 32 | # Thumbnails 33 | ._* 34 | 35 | # Files that might appear in the root of a volume 36 | .DocumentRevisions-V100 37 | .fseventsd 38 | .Spotlight-V100 39 | .TemporaryItems 40 | .Trashes 41 | .VolumeIcon.icns 42 | .com.apple.timemachine.donotpresent 43 | 44 | # Directories potentially created on remote AFP share 45 | .AppleDB 46 | .AppleDesktop 47 | Network Trash Folder 48 | Temporary Items 49 | .apdisk 50 | 51 | ### macOS Patch ### 52 | # iCloud generated files 53 | *.icloud 54 | 55 | ### Windows ### 56 | # Windows thumbnail cache files 57 | Thumbs.db 58 | Thumbs.db:encryptable 59 | ehthumbs.db 60 | ehthumbs_vista.db 61 | 62 | # Dump file 63 | *.stackdump 64 | 65 | # Folder config file 66 | [Dd]esktop.ini 67 | 68 | # Recycle Bin used on file shares 69 | $RECYCLE.BIN/ 70 | 71 | # Windows Installer files 72 | *.cab 73 | *.msi 74 | *.msix 75 | *.msm 76 | *.msp 77 | 78 | # Windows shortcuts 79 | *.lnk 80 | 81 | # End of https://www.toptal.com/developers/gitignore/api/windows,macos,linux,dotenv 82 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # minecraft-proxy 2 | 3 | Proxy your local Minecraft server with a public server using your domain. It's not a Bungeecord or a plugin. 4 | 5 | ## Structure 6 | 7 | Use [frp](https://github.com/fatedier/frp) to connect the local server to the container's port with the public server. Then use [mc-router](https://github.com/itzg/mc-router) to change the port to connect by domain. 8 | 9 | ```mermaid 10 | flowchart LR 11 | subgraph Public server 12 | subgraph Container 13 | subgraph frps 14 | frps-25566[:25566] 15 | frps-25567[:25567] 16 | end 17 | mc-router <-- example.com --> frps-25566 18 | mc-router <-- sub.example.com --> frps-25567 19 | end 20 | end 21 | subgraph Local server 2 22 | frps-25567 <---> frpc-2 23 | minecraft-2[Minecraft server] <--> frpc-2[frpc] 24 | end 25 | subgraph Local server 1 26 | minecraft-1[Minecraft server] <--> frpc-1[frpc] 27 | frps-25566 <---> frpc-1 28 | end 29 | minecraft-client[Minecraft client] <-- $domain:25565 --> mc-router 30 | ``` 31 | 32 | ## Usage 33 | 34 | ### Public server 35 | 36 | 1. Clone this repository. 37 | 2. Create `.env`. 38 | 3. Run `docker compose up -d`. 39 | 40 | ### Each local server 41 | 42 | 1. Download from [releases](https://github.com/fatedier/frp/releases). 43 | 2. Extract frpc from a downloaded file. 44 | 3. Create `frpc.ini` 45 | 4. Run `frpc -c frpc.ini`. 46 | 47 | ## Example 48 | 49 | ### Structure example 50 | 51 | ※ The public server address is `203.0.113.0`. 52 | 53 | #### Public server 54 | 55 | ##### .env 56 | 57 | ```dotenv 58 | ROUTER_MAPPING=example.com=frp:25566,sub.example.com=frp:25567 59 | ``` 60 | 61 | ※ `frp` is the address that means frps container. 62 | 63 | #### Local server 1 64 | 65 | ##### frpc.ini 66 | 67 | ```ini 68 | [common] 69 | server_addr = 203.0.113.0 70 | server_port = 7000 71 | 72 | [minecraft] 73 | type = tcp 74 | local_port = 25565 75 | remote_port = 25566 76 | ``` 77 | #### Local server 2 78 | 79 | ##### frpc.ini 80 | 81 | ```ini 82 | [common] 83 | server_addr = 203.0.113.0 84 | server_port = 7000 85 | 86 | [minecraft] 87 | type = tcp 88 | local_port = 25565 89 | remote_port = 25567 90 | ``` 91 | 92 | ## Environment value 93 | 94 | ### `FRP_VERSION` 95 | 96 | Default: [`0.60.0`](https://github.com/fatedier/frp/releases/v0.60.0) 97 | 98 | frps version to use. 99 | 100 | ### `FRP_ARGS` 101 | 102 | Default: (empty) 103 | 104 | frps command options. For example, you can set a token. 105 | 106 | ### `FRP_PORT` 107 | 108 | Default: 7000 109 | 110 | ### `ROUTER_MAPPING` 111 | 112 | **Require** 113 | 114 | Mapping of address and port. For example: `example.com=frp:25565` 115 | --------------------------------------------------------------------------------