How to Set Up FRP with Docker Compose

FRPS (Server Setup)

Step 1:

Install Docker (defaults to latest version)

curl -fsSL https://get.docker.com | bash -s docker

Step 2:

On the VPS, enter the command to create a directory: mkdir -p /root/data/docker_data/frps

Enter the directory cd /root/data/docker_data/frps and enter the command touch docker-compose.yml to create the configuration file. Copy the code below into the configuration file.

services:
    frps:
        restart: always
        network_mode: host
        volumes:
            - '/root/data/docker_data/frps/frps.toml:/etc/frp/frps.toml'
        container_name: frps
        image: snowdreamtech/frps:0.56.0

Step 3:

Enter the command touch frps.toml to create the configuration file. Copy the code below into the configuration file.

# frps.toml 
bindPort = 1341 # Port for server and client communication 
transport.tls.force = true # Server will only accept TLS connections
auth.token = "dg233eg443u" # Authentication token, must match frpc

# Server Dashboard, for viewing frp service status and statistics
webServer.addr = "0.0.0.0" # Backend management address, no change needed here
webServer.port = 13442 # Backend management port
webServer.user = "admin" # Backend login username
webServer.password = "admin" # Backend login password

Finally, run docker compose up -d to install.

At this point, our FRPS server setup is complete.

FRPC Setup (Client Setup)

Step 1: Install Docker, follow the steps above.

Step 2:

On the VPS, enter the command to create a directory: mkdir -p /root/data/docker_data/frpc

Enter the directory cd /root/data/docker_data/frpc and enter the command touch docker-compose.yml to create the configuration file. Copy the code below into the configuration file.

version: '3.3'
services:
    frpc:
        restart: always
        network_mode: host
        volumes:
            - '/root/data/docker_data/frpc/frpc.toml:/etc/frp/frpc.toml'
        container_name: frpc
        image: snowdreamtech/frpc:0.56.0

Step 3:

Enter the command touch frpc.toml to create the configuration file. Copy the code below into the configuration file.

# frpc.toml  
transport.tls.enable = true   # Starting from v0.50.0, the default value for transport.tls.enable is true
serverAddr = "111.111.111.111"    # Public IP to connect to, replace with your own IP
serverPort = 1341    # Public server communication port, needs to match the server's
auth.token = "dg233eg443u"    # Token, must match the public server's

[[proxies]]
name = "test-http"     # If multiple proxies are needed, change the name here
type = "tcp"    # Proxy protocol. For details, refer to the official website https://gofrp.org/zh-cn/docs/examples/
localIP = "192.168.31.21"    # Local IP, change to your own
localPort = 3444    # Local port of the service being set up
remotePort = 1343    # External access port

Finally, run docker compose up -d to install.

And you're all set! Finally, just access it via IP:port.

WIN FRPC Setup (Client Setup)

Step 1:

Go to the URL below to download the corresponding Windows version. If you are not sure about your architecture, you can try frp_0.56.0_windows_amd64.zip.

Give it a try. If it doesn't work, try another one.

https://github.com/fatedier/frp/releases/tag/v0.56.0

Step 2:

Copy the code below into the configuration file (frpc.toml)

# frpc.toml  
transport.tls.enable = true   # Starting from v0.50.0, the default value for transport.tls.enable is true
serverAddr = "111.111.111.111"    # Public IP to connect to, replace with your own IP
serverPort = 1341    # Public server communication port, needs to match the server's
auth.token = "dg233eg443u"    # Token, must match the public server's

[[proxies]]
name = "test-http"     # If multiple proxies are needed, change the name here
type = "tcp"    # Proxy protocol. For details, refer to the official website https://gofrp.org/zh-cn/docs/examples/
localIP = "192.168.31.21"    # Local IP, change to your own
localPort = 3444    # Local port of the service being set up
remotePort = 1343    # External access port

Step 3:

In the frpc folder, create a new text document, rename it to 双击运行.bat (Double-click to run.bat), copy cmd /k "frpc.exe -c frpc.toml" into it, and save. Finally, double-click it to run!

And you're all set! Finally, just access it via IP:port.

Advanced Section (Enable HTTPS Protocol)

FRPS (Server Setup) Copy the code below into the configuration file (frps.toml)

# frps.toml 
bindPort = 1341 # Port for server and client communication 
vhostHTTPSPort = 443
transport.tls.force = true # Server will only accept TLS connections
auth.token = "dg233eg443u" # Authentication token, must match frpc

# Server Dashboard, for viewing frp service status and statistics
webServer.addr = "0.0.0.0" # Backend management address, no change needed here
webServer.port = 13442 # Backend management port
webServer.user = "admin" # Backend login username
webServer.password = "admin" # Backend login password

WIN FRPC Setup (Client Setup) Copy the code below into the configuration file (frpc.toml)

Place the certificate files in the same directory. The configuration file below is for running on Windows. It doesn't work with Docker??? I tested it and had issues, so I switched to running it on Windows. If any friends know the reason, please share it so I can improve the tutorial.

serverAddr = "111.111.111.111"    # Public IP to connect to, replace with your own IP
serverPort = 1341    # Public server communication port, needs to match the server's
auth.token = "dg233eg443u"    # Token, must match the public server's

[[proxies]]
name = "test_htts2http" # No change needed
type = "https" # No change needed
customDomains = ["qq.qq.com"] # Replace with your own domain name

[proxies.plugin]
type = "https2http" # No change needed
localAddr = "192.168.11.11:5555" # Local IP and port, change to your own
crtPath = "./qq.qq.com.cer" # Certificate path, replace qq.qq.com.cer with your own
keyPath = "./qq.qq.com.key" # Key path, replace qq.qq.com.key with your own
hostHeaderRewrite = "127.0.0.1" # No change needed
requestHeaders.set.x-from-where = "frp" # No change needed

Comments