frp内网穿透

服务端搭建:

下载:

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

  1. 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
  1. 使用sudo systemctl enable frpc.service启用
  2. sudo service frpc start

Mac 开机启动设置
建议放在 ~/Library/LaunchAgents 下面。
vim xyz.chaisz.frp.plist




  
    Label
    xyz.chaisz.frp
    RunAtLoad
    
    ProgramArguments
    
        /usr/local/opt/frp/frpc
        -c
        /usr/local/opt/frp/frpc.ini
    
  

参考:
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

效果:


屏幕快照 2018-03-28 下午10.54.34.png
屏幕快照 2018-03-28 下午10.53.55.png
屏幕快照 2018-03-28 下午10.54.09.png

配置:


屏幕快照 2018-03-28 下午11.00.15.png

屏幕快照 2018-03-28 下午11.04.25.png

推荐阅读:
https://github.com/fatedier/frp/blob/master/README_zh.md
https://www.hi-linux.com/posts/25686.html

你可能感兴趣的:(frp内网穿透)