今后可以通过树莓派,来吧家里的机器开放出来
申请证书,并上传到服务器/opt/frp/ssl
/var/opt/gitlab/nginx/conf
目录中,生成配置文件frp_nginx_https.conf
server {listen 80;server_name frp.redhtc.com;server_tokens off;## Don't show the nginx version number, a security best practicelocation / {proxy_set_header X-Real-IP $remote_addr;proxy_set_header Host $http_host;proxy_pass http://127.0.0.1:20181;}}server {listen 443;server_name frp.redhtc.com;server_tokens off;ssl on;root html;index index.html index.htm;ssl_certificate /opt/frp/ssl/7815660_frp.redhtc.com.pem;ssl_certificate_key /opt/frp/ssl/7815660_frp.redhtc.com.key;ssl_session_timeout 5m;ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;ssl_protocols TLSv1 TLSv1.1 TLSv1.2;ssl_prefer_server_ciphers on;location / {# 下面代码是用来通过80端口访问的 20180proxy_set_header Host $host;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://127.0.0.1:20181;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";}}
让 nginx 可以找到这个文件
include /var/opt/gitlab/nginx/conf/frp_nginx_https.conf;
这里使用了gitlab
的nginx
gitlab-ctl restart nginx
打开火狐输入:http://frp.redhtc.com/ 提示:502 Bad Gateway
将frp_0.42.0_linux_amd64.tar.gz
上传到/opt/frp
目录下。并使用下面命令解压。
tar -zxvf frp_0.42.0_linux_amd64.tar.gz
修改 frps.ini 文件,设置监听 HTTP 请求端口为 20181:
[common]bind_port = 27000vhost_http_port = 20181token = fanhualei****
cd /opt/frp/frp_0.42.0_linux_amd64# 进入后台要先查查这个启动了吗# nohup 英文全称 no hang up(不挂起),用于在系统后台不挂断地运行命令,退出终端不会影响程序的运行。ps -ef|grep frpnohup ./frps -c ./frps.ini &
显示:The page you requested was not found. The server is powered by frp.
[common]server_addr = 47.92.0.**server_port = 27000token = fanhualei****[web]type = httplocal_port = 8000custom_domains = frp.redhtc.com
local_port = 8000
是本地 web 服务的地址
./frpc -c ./frpc.ini
打开浏览器输入frp.redhtc.com