服务端搭建:
下载:
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 = token
admin_addr = 127.0.0.1
admin_port = 7400
[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 2333
[vnc]
type = tcp
local_ip = 127.0.0.1
local_port = 5900
remote_port = 5900
[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开机启动
https://github.com/fatedier/frp/issues/176
sudo vim /etc/systemd/system/frpc.service
[Unit]
Description=frpc daemon
After=syslog.target network.target
Wants=network.target
[Service]
Type=simple
ExecStart=/usr/sbin/frp/frpc -c /etc/frp/frpc.ini
Restart= always
RestartSec=1min
ExecStop=/usr/bin/killall frpc
[Install]
WantedBy=multi-user.target
- 使用
sudo systemctl enable frpc.service
启用 sudo service frpc start
Mac 开机启动设置
建议放在 ~/Library/LaunchAgents
下面。
vim xyz.chaisz.frp.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>xyz.chaisz.frp</string>
<key>RunAtLoad</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/frp/frpc</string>
<string>-c</string>
<string>/usr/local/opt/frp/frpc.ini</string>
</array>
</dict>
</plist>
参考:
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
效果:
配置:
推荐阅读:
https://github.com/fatedier/frp/blob/master/README_zh.md
https://www.hi-linux.com/posts/25686.html