FRP (Fast Reverse Proxy) Setup on Linux Machine to bypass CGNAT. [Self-Hosting] Updated Doc: Feb 2025
This guide provides step-by-step instructions to download, configure, test, and set up FRP (frps
for the server and frpc
for the client) as a systemd service on Ubuntu/Debian systems.
Prerequisites
-
Server: A machine with a public IP address to host
frps
. -
Client: A machine (behind NAT or firewall) where
frpc
will run. -
Both Machines: Ubuntu/Debian operating system with
wget
installed.
1. Download and Install FRP
On the Server (Public Machine)
- Download latest FRP [Choose package according to machine architecture]:
wget https://github.com/fatedier/frp/releases/download/v0.61.1/frp_0.61.1_linux_amd64.tar.gz
- Extract the Archive:
tar -zxvf frp_0.61.1_linux_amd64.tar.gz
-
Edit
frps
Configuration File:
cd frp_0.61.1_linux_amd64
sudo nano frps.toml
Update the following content if required:
bind_port = 7000
auth.token = "mysecret"
On the Client (Local Machine)
- Download latest FRP [Choose package according to machine architecture]:
wget https://github.com/fatedier/frp/releases/download/v0.61.1/frp_0.61.1_linux_amd64.tar.gz
- Extract the Archive:
tar -zxvf frp_0.61.1_linux_amd64.tar.gz
-
Edit
frpc
Configuration File:
cd frp_0.61.1_linux_amd64
sudo nano frpc.toml
Add the following content:
server_addr = "x.x.x.x" # Replace with your server's public IP
server_port = 7000
auth.token = "mysecret"
login_fail_exit = false
[[proxies]]
name = "example1"
type = "tcp"
local_port = 81
remote_port = 6000
[[proxies]]
name = "example2"
type = "tcp"
local_port = 83
remote_port = 6001
- NOTE: Need to allow these remote ports on frps [server with public ip] firewall.
2. Testing the Setup
On the Server
-
Start
frps
Manually:
frps -c /etc/frp/frps.toml
On the Client
-
Start
frpc
Manually:
frpc -c /etc/frp/frpc.toml
-
Test Connections:
- Access the services exposed via the server's public IP on ports 6000 and 6001 to ensure they're correctly forwarded to the client's local services on ports 81 and 83, respectively.
3. Setting Up as a Systemd Service
To ensure that FRP starts on boot and can be managed easily, set up both frps
and frpc
as systemd services.
On the Server
-
Copy binary and config file to required places
sudo cp frp_0.61.1_linux_amd64/frps /usr/local/bin/ sudo mkdir -p /etc/frp sudo cp frp_0.61.1_linux_amd64/frps.toml /etc/frp/
Create Systemd Service File for
frps
:
sudo nano /etc/systemd/system/frps.service
Add the following content:
[Unit]
Description=FRP Server Service
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/frps -c /etc/frp/frps.toml
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
-
Reload Systemd and Start
frps
Service:
sudo systemctl daemon-reload
sudo systemctl enable frps
sudo systemctl start frps
- Check Service Status:
sudo systemctl status frps
On the Client
-
Copy binary and config file to required places
sudo cp frp_0.61.1_linux_amd64/frpc /usr/local/bin/ sudo mkdir -p /etc/frp sudo cp frp_0.61.1_linux_amd64/frpc.toml /etc/frp/
Create Systemd Service File for
frpc
:
sudo nano /etc/systemd/system/frpc.service
Add the following content:
[Unit]
Description=FRP Client Service
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/frpc -c /etc/frp/frpc.toml
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
-
Reload Systemd and Start
frpc
Service:
sudo systemctl daemon-reload
sudo systemctl enable frpc
sudo systemctl start frpc
- Check Service Status:
sudo systemctl status frpc
By following these steps, you will have successfully set up FRP on both your server and client machines, allowing seamless access to services behind NAT or firewalls.
Also after testing or setup up full you can then use Nginx proxy manager or any other reverse proxy on the server with public ip to add reverse proxy to the remote ports with the required domain etc. Note the hostname for a proxy should be entered as the server's internal ip or if not available then public ip because localhost/127.0.0.1 will not work.
Top comments (0)