This is a complete tutorial on deploying frp (Fast Reverse Proxy). Through this tutorial, you can easily expose your home NAS or local test server to the public internet, enabling access from anywhere.
Must-read before proceeding:
- Please confirm you have a cloud server with a fixed public IPv4 address.
- Tutorial commands include
sudowhere appropriate. If you encounterpermission deniedduring deployment, addsudobefore the command.- This tutorial uses the mainstream
x86_64 (amd64)architecture Linux as an example.- Windows deployment instructions will be added later.
Phase 1: Cloud Server (frps) Deployment
1. Install Basic Dependencies
First, we need to install the software packages we’ll use. Choose the command based on your Linux distribution.
Debian / Ubuntu family:
Update package sources:
sudo apt update |
Install required packages:
sudo apt install curl tar -y |
RHEL / Fedora / CentOS / Rocky and other Red Hat family:
Update package sources:
sudo dnf update |
Install required packages:
sudo dnf install curl tar -y |
2. Download and Extract frp
We need to download the version matching our server’s system and architecture. Personal computers and most cloud servers are amd64 (i.e., x86_64).
Choose a directory to store files. Here we use /home/your-username/Documents/ (you can place it anywhere, just remember the path).
Navigate to the directory:
cd ~/Documents |
Next, download the frp archive. The official download address is provided below. If GitHub access is slow in your region, you can use the accelerated proxy I’ve provided.
Download using official URL:
curl -O https://github.com/fatedier/frp/releases/download/v0.67.0/frp_0.67.0_linux_amd64.tar.gz |
Or download using the accelerated proxy:
curl -O https://proxy.kokode.su/github/fatedier/frp/releases/download/v0.67.0/frp_0.67.0_linux_amd64.tar.gz |
Extract the downloaded archive:
tar -zxvf frp_0.67.0_linux_amd64.tar.gz |
For easier management, rename the extracted folder to frps and enter it:
Rename the folder:
mv frp_0.67.0_linux_amd64 frps |
Enter the frps directory:
cd frps |
Remove client files not needed on the server to keep the directory clean:
rm -rf frpc* |
Use ls to confirm only server files remain:
ls |
Expected output:
frps frps.toml LICENSE |
3. Configure frps.toml
As a precaution, let’s back up the default configuration, clear it, and check the status:
Backup and clear configuration:
cp frps.toml frps.toml.bak && echo -n > frps.toml && cat frps.toml |
Note: If the config file is successfully cleared, there will be no output in the terminal.
Edit the configuration file with vim:
vim frps.toml |
Tip: Press
ito enter vim’s edit mode, then paste the following content. You can reference my configuration, but be sure to modify the password and token according to your needs.
bindPort = 7000 |
After pasting and modifying, press Esc to exit edit mode, type :wq and press Enter to save and exit.
4. Set Up Systemd Auto-Start
To ensure frps runs automatically after server restarts, we need to register it as a system service.
Create and edit the service configuration file:
sudo vim /etc/systemd/system/frps.service |
Absolute Path Warning: Systemd configuration files cannot use
~to represent the user directory! Be sure to replace/home/your-username/below with the actual absolute path where you stored frps.
Press i to enter edit mode, then paste the following:
[Unit] |
Press Esc to exit edit mode, type :wq and press Enter to save and exit.
Reload systemd configuration:
sudo systemctl daemon-reload |
Enable auto-start and start the service immediately:
sudo systemctl enable --now frps.service |
Common service management commands:
Check if the service is running normally:
sudo systemctl status frps.service |
Stop the service:
sudo systemctl stop frps.service |
Restart the service:
sudo systemctl restart frps.service |
Disable auto-start:
sudo systemctl disable frps.service |
At this point, the cloud server configuration is complete!
Phase 2: Local Client (frpc) Deployment
Assuming the local device we need to penetrate (server / NAS) also runs Linux. The frpc client deployment process is similar to frps. Here are the specific steps.
1. Download and Extract
Basic dependency installation is the same as above. Download and extract files to your preferred directory (still using /home/your-username/Documents/ as an example):
Navigate to the directory:
cd ~/Documents |
Download the archive (using proxy URL as an example):
curl -O https://proxy.kokode.su/github/fatedier/frp/releases/download/v0.67.0/frp_0.67.0_linux_amd64.tar.gz |
Extract the file:
tar -zxvf frp_0.67.0_linux_amd64.tar.gz |
This time, rename it to frpc and enter the directory:
Rename the folder:
mv frp_0.67.0_linux_amd64 frpc |
Enter the frpc directory:
cd frpc |
Remove unused server files:
rm -rf frps* |
Use ls to confirm only client files remain:
ls |
Expected output:
frpc frpc.toml LICENSE |
2. Configure frpc.toml
As a precaution, let’s back up and clear the default configuration:
Backup and clear configuration:
cp frpc.toml frpc.toml.bak && echo -n > frpc.toml && cat frpc.toml |
Edit the configuration file with vim:
vim frpc.toml |
Press i to enter edit mode, paste the following client configuration reference. Read the comments carefully to understand the modular configuration logic:
# --- Global Configuration --- |
After pasting and modifying, press Esc to exit edit mode, type :wq and press Enter to save and exit.
Note: To add new configurations, you only need to add the following block:
[[proxies]] |
Pitfall Guide:
- When adding new configurations,
namemust never be duplicated.- The
remotePortin the configuration (e.g., 2222, 5678, 6789) must be allowed in your cloud provider’s console (Alibaba Cloud/Tencent Cloud, etc.) firewall/security group, otherwise even if it starts successfully, you won’t be able to connect!
After each configuration change, be sure to restart the client service for it to take effect:
Supplement: If errors occur, refer to “3. Set Up Systemd Auto-Start” to configure Systemd
sudo systemctl restart frpc.service |
3. Set Up Systemd Auto-Start
Similarly, register it as a system service:
Create and edit the service configuration file:
sudo vim /etc/systemd/system/frpc.service |
Reminder again: Replace all
/home/your-username/below with actual absolute paths.
Press i to enter edit mode, paste the following:
[Unit] |
(Note: If you encounter permission issues during startup, comment out DynamicUser=yes and replace with User=your-username)
Press Esc to exit edit mode, type :wq and press Enter to save and exit.
Reload systemd configuration:
sudo systemctl daemon-reload |
Enable auto-start and start the service immediately:
sudo systemctl enable --now frpc.service |
Confirm the client is running normally:
sudo systemctl status frpc.service |
If you see active (running), the intranet penetration has been successfully deployed! You can now test connecting to your local service via the public IP.
[Supplement] Advanced Tips: How to Update Configuration Without Disconnecting?
In actual use, if you want to add a penetration port without restarting frpc (which would disconnect ongoing connections like SSH or large file transfers), consider these two approaches:
Option A: Use Hot Reload (Recommended)
FRP supports reloading configuration files without stopping the service. Since we’ve already written the ExecReload directive in the Systemd configuration, you just need to:
- Modify
frpc.tomlto add new configuration. - Execute in terminal:Effect: FRP will automatically read the new configuration and apply it, while existing connections remain uninterrupted.
sudo systemctl reload frpc.service
Option B: Multi-Instance Parallel (Suitable for Categorized Management)
If you want to physically isolate different services (e.g., one config file for NAS, another for development servers), you can run multiple frpc instances:
- Create new config: Create a new config file in the directory, e.g.,
frpc2.toml. - Register new service: Copy and create a new Systemd service file:
sudo cp /etc/systemd/system/frpc.service /etc/systemd/system/frpc2.service
- Modify new service file: Point
ExecStartinfrpc2.serviceto the newfrpc2.toml. - Start new service:Note: Even with different instances, as long as they connect to the same frps server, the
sudo systemctl enable --now frpc2.service
name(task name) in the configuration must never be duplicated, otherwise connection will fail.
About this Post
This post is written by 青空由依(AozoraYui)/青空由纪(AozoraYuki)/青空葵(AozoraAoi), licensed under CC BY-NC 4.0.
Next
KDE Plasma Experience Optimization: Fixing Login Focus, Numlock, and Function Key Mapping
Previous