Preface: Through fpr, I can remotely access my device, and can remotely view and control the Raspberry Pi.
Article directory
1. Preparation tools
1. Server (I use a relatively cost-effective Tencent cloud server)
2.frp
3. Raspberry Pi
2. Operation steps
1. Download frp
(1) It is recommended to download it to your computer first, and then use xftp ( xftp free tutorial ) to upload to the Raspberry Pi and the server. frp download link . I also put the zipped package in the network disk , if you need it, you can pick it up yourself, and the password is 1111.
(2) Upload to the server and Raspberry Pi via xftp.
2. Configure the server
(1) Unzip and enter the folder
sudo tar -xzvf frp_0.38.0_linux_amd64.tar.gz
cd frp_0.38.0_linux_amd64
(2) Configure the frps.ini file
sudo nano frps.ini
to write
[common]
bind_port = 7001
vhost_http_port =7001
Ctrl+s, Ctrl+x, save and exit
(3) The server opens port 7001 (you can set a different port by yourself, and it must correspond to the configuration in the frps
. system, so I have to open port 7001 in both systems.
(4) Start frps under the frp_0.38.0_linux_amd64 folder,
./frps -c ./frps.ini
Start successfully
3. Configure Raspberry Pi
(1) Similarly, unzip and enter the folder
sudo tar -xzvf frp_0.38.0_linux_arm.tar.gz
cd frp_0.38.0_linux_arm
(2) Configure the frps.ini file
sudo nano frpc.ini
to write
[common]
# ***处填入填入你服务器的公网ip
server_addr = *******
# 开放的端口号
server_port = 7001
[web]
type = http
#此处为树莓派开放的端口号
local_port = 8081
# ***处填入填入你服务器的公网ip
custom_domains = ***
Ctrl+s, Ctrl+x, save and exit
(3) start
Start the test under the frp_0.38.0_linux_arm folder
./frpc -c ./frpc.ini
success, showing that the startup is successful.
4. Remote real-time video
1. Start motion on the Raspberry Pi ( you can check this article for the installation and configuration of motion )
sudo motion
(1) View in the LAN (192.168.137.xx is your own Raspberry Pi ip address)
and enter in the browser: http://192.168.137.xx:8081/
(2) Remote view on the public network (192.168.137.xx is your own public ip address)
in the browser Input: http://192.168.137.xx:7001/
The delay is relatively high, and the delay on my side can be more than ten seconds. (Please continue to read down, there is a delay of tens of ms)
2. Important! ! ! Smooth mjpg-streamer is here! Pro-test the public network delay is about 100ms
(1) Start mjpg-streamer ( see this article for the installation and configuration of mjpg-streamer )
Let’s kill motion first
sudo killall -TERM motion
Go to the /mjpg-streamer/mjpg-streamer-experimental folder to execute the startup command
sudo ./start.sh
Start successfully
(1) View in LAN (192.168.137.xx is your own Raspberry Pi ip address)
Enter in the browser: http://192.168.137.xx:8081/
very smooth
(2) Remote view on public network (192.168.137.xx is your public network ip address )
Input in the browser: http://192.168.137.xx:7001/
the effect is good, within 100ms, does not affect the live broadcast, yeah!
5. Set quick start
(1) The server
enters the system directory
cd /lib/systemd/system
sudo nano frps.service
write the following code
[Unit]
Description=frps service
After=network.target syslog.target
Wants=network.target
[Service]
Type=simple
User=nobody
Restart=on-failure
RestartSec=5s
#启动服务的命令(此处写你的frps的实际安装目录)
ExecStart=/lishouhao/frp_0.38.0_linux_amd64/frps -c /lishouhao/frp_0.38.0_linux_amd64/frps.ini
ExecReload=/lishouhao/frp_0.38.0_linux_amd64/frps reload -c /lishouhao/frp_0.38.0_linux_amd64/frps.ini
[Install]
WantedBy=multi-user.target
Ctrl+s, Ctrl+x, save and exit
(2) The same is true for the Raspberry Pi.
Note: the cloud server is an frps file, and the Raspberry Pi is an frpc file. Be careful when modifying related configurations.
(3) Quick start method
# 启动frps
systemctl start frpc
# 打开开机自启动
systemctl enable frpc
# 关闭开机自启动
systemctl disable frpc
# 重启应用
systemctl restart frpc
# 停止应用
systemctl stop frpc
# 查看应用的日志
systemctl status frpc
Summarize
Personal understanding, frp is a bridge connecting the public network and the intranet, as long as the port is configured, communication can be carried out. When configuring, pay attention to distinguish between frps and frpc.
I am also new to Xiaobai. As the saying goes, a good memory is not as good as a bad pen. I use this article to record my exploration process. If there is any discomfort in the article, please criticize it.