服务端搭建:
下载:
https://github.com/fatedier/frp/releases
配置:
服务端:
[common]
bind_addr = 服务器IP
bind_port = 7000
vhost_http_port = 80
vhost_https_port = 443
dashboard_port = 7500
dashboard_user = username
dashboard_pwd = password
privilege_mode = true
privilege_token = frp
运行:
./frps -c ./frps.ini
后台运行:
nohup ./frps -c ./frps.ini & #启动服务端 带&符号
客户端:
[common]
server_addr = 服务器IP
server_port = 7000
privilege_token = frp
[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 2333
[http]
type = http
local_port = 80
remote_port = 80
custom_domains = www.raspberry.com
[https]
type = https
local_port = 443
remote_port = 443
custom_domains = www.raspberry.com
启动:
./frpc -c ./frpc.ini
后台运行:
nohup ./frpc -c ./frpc.ini & #启动服务端 带&符号
到这一步还没成功,接下来要开启树莓派Nginx服务
LNMP环境搭建
配置参考:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name www.raspberry.com;
location / {
index index.php index.html index.htm;
}
location ~ \.php$ {
include fastcgi.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}
server {
add_header Strict-Transport-Security "max-age=10886400; includeSubDomains; preload";
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
listen 443 ssl ;
listen [::]:443 ssl ;
ssl_certificate /etc/nginx/ssl/214566258240625.pem;
ssl_certificate_key /etc/nginx/ssl/214566258240625.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
root /var/www/html;
index index.html index.htm;
server_name www.raspberry.com;
location / {
index index.php index.html index.htm;
}
location ~ \.php$ {
include fastcgi.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}
接下来把你的域名解析到服务器的IP就可以通过域名来访问你的树莓派了。
frp开机启动
cd /etc/init.d
sudo vim frp
#!/bin/bash
#
# This starts and stops frp
#
### BEGIN INIT INFO
# Provides: frp
# Required-Start: $network
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: frp service
# Description: This service is connect world
### END INIT INFO
case "$1" in
start)
echo "Starting frp"
nohup /usr/local/application/frp/frpc -c /usr/local/application/frp/frpc.ini &
;;
stop)
echo "Stopping frp"
#killall frpc
kill -9 $(pidof frpc)
;;
*)
echo "Usage: service frp start|stop"
exit 1
;;
esac
exit 0
-
sudo chmod a+x /etc/init.d/frp
开启执行权限 -
sudo update-rc.d frp defaults
加入开机启动 -
sudo reboot
重启
可以用 sudo service frp start/stop
来开启/停止frp
参考:
https://github.com/fatedier/frp/blob/master/README_zh.md
https://segmentfault.com/a/1190000009353002
https://blog.csdn.net/sinat_27938829/article/details/73436739
关闭防火墙:
https://www.jianshu.com/p/bad33004bb4f (有风险)
后台运行 :
https://www.jianshu.com/p/93bf511ea72e
效果:




配置:


ssh 远程连接可正常使用,web访问找不到页面。
网友评论