Fast Reverse Proxy (FRP) is a self-hosted reverse proxy that allows you to tunnel traffic to your local development environment. This mitigates the need to open ports on your router or use a service like Cloudfront to expose your local server to the internet.
Table of contents
Open Table of contents
What is a Reverse Proxy?
A reverse proxy is a server that sits between a client and one or more servers. It intercepts requests from clients and forwards them to the appropriate server. Reverse proxies are commonly used to improve performance, security, and reliability by distributing client requests across multiple servers.
In this article, we’ll focus on setting up a reverse proxy to tunnel traffic between local envirements, but the same principles can be applied to a VPS or cloud server.
Setup Fast Reverse Proxy (FRP)
First of, you’ll need to download the FRP binary from the official website. Choose the appropriate version for your operating system and architecture.
We will use the linux_amd64
version for this tutorial.
Then extract the downloaded file and navigate to the extracted directory.
Desktop % tar -xvf frp_0.58.1_linux_amd64.tar.gz &&
cd frp_0.58.1_linux_amd64
Once extracted, you’ll have two files: frpc
and frps
.
frpc
is the client that runs on your local machine.frps
is the server that runs on your VPS or cloud server.
Setting up the Server
First, we’ll set up the server on your VPS or cloud server.
- Copy the
frps
file and thefrps.toml
configuration file to your server. Thefrps.toml
file contains the configuration settings for the server.
bindPort = 7000
This bindPort
setting specifies the port that the server listens on.
- Start the server by running the following command:
./frps -c frps.toml
The server should now be running and listening on port 7000.
- On the client side, copy the
frpc
file and thefrpc.toml
configuration file to your local machine. frpc.toml
needs to be configured with the server’s IP address and port.
serverAddr = "192.168.1.50"
serverPort = 7000
[[proxies]]
name = "test-tcp"
type = "tcp"
localIP = "localhost"
localPort = 22
remotePort = 6000
serverAddr
andserverPort
specify the IP address and port of the VPS.localIP
andlocalPort
specify the IP address and port of the local server. and should be set tolocalhost
and the port of the service you want to expose.remotePort
specifies the port on the server that a client can connect to.
- Start the client by running the following command:
./frpc -c frpc.toml
The client should now be running and connected to the server.
Conclusion
Once the server and client are set up, you can access the client server through the remote server’s IP, in this case, 192.168.1.50:6000
, which will tunnel traffic to the local client server on port 22
.