centos7环境下frp源码编译及404页面修改教程

和黑猫之家聊聊?

前言
frp 是一个高性能的反向代理应用,可以轻松地进行内网穿透,对外网提供服务,支持 TCP、UDP、HTTP、HTTPS 等协议类型,并且 web 服务支持根据域名进行路由转发。
Github: https://github.com/fatedier/frp
当然frp作者已经提供多达20种已编译好的各种版本可以供大家使用,几乎不需要自己编译。
但是有时候我们需要自定义一些内容,这时候就需要自行编译了。

搭建GO环境

1、下载二进制包:go1.11.5.linux-amd64.tar.gz。
cd /root/
wget  https://dl.google.com/go/go1.11.5.linux-amd64.tar.gz

2、将下载的二进制包解压至 /usr/local目录。
tar -C /usr/local -xzf  go1.11.5.linux-amd64.tar.gz

3、将 /usr/local/go/bin 目录添加至PATH环境变量:
vim  /etc/profile
最后增加如下一行
export PATH=$PATH:/usr/local/go/bin

centos7环境下frp源码编译及404页面修改教程 linux学习 第1张centos7环境下frp源码编译及404页面修改教程 linux学习 第2张

centos7环境下frp源码编译及404页面修改教程 linux学习 第3张

下载编译frp

直接运行以下命令
cd  /root/
go get github.com/fatedier/frp
cd /root/go/src/github.com/fatedier/frp
make -f Makefile.cross-compiles

centos7环境下frp源码编译及404页面修改教程 linux学习 第4张

centos7环境下frp源码编译及404页面修改教程 linux学习 第5张

修改404页面

404页面在源码路径utils/vhost/resource.go文件里

centos7环境下frp源码编译及404页面修改教程 linux学习 第6张

centos7环境下frp源码编译及404页面修改教程 linux学习 第7张

改完之后再从新编译下就可以了。

404html模板1:

<!DOCTYPE html>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>404 找不到此页面/(ㄒoㄒ)/~~</title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><style>*{padding:0;margin:0}a{text-decoration:none}.notfoud-container .img-404{height:155px;background:url(https://me.heimaoba.cn/frp_404.png) center center no-repeat;-webkit-background-size:150px auto;margin-top:40px;margin-bottom:20px}.notfoud-container .notfound-p{line-height:22px;font-size:17px;padding-bottom:15px;border-bottom:1px solid #f6f6f6;text-align:center;color:#262b31}.notfoud-container .notfound-reason{color:#9ca4ac;font-size:13px;line-height:13px;text-align:left;width:210px;margin:0 auto}.notfoud-container .notfound-reason p{margin-top:13px}.notfoud-container .notfound-reason ul li{margin-top:10px;margin-left:36px}.notfoud-container .notfound-btn-container{margin:40px auto 0;text-align:center}.notfoud-container .notfound-btn-container .notfound-btn{display:inline-block;border:1px solid #ebedef;background-color:#239bf0;color:#fff;font-size:15px;border-radius:5px;text-align:center;padding:10px;line-height:16px;white-space:nowrap}</style></head><body>

    <div class="notfoud-container">
        <div class="img-404">
        </div>
        <p class="notfound-p">哎呀迷路了...</p>
        <div class="notfound-reason">
            <p>可能的原因:</p>
            <ul>
                <li>frpc没有启动成功</li>
                <li>域名不正确</li>
                <li>内网端不存在该页面</li>
                <li>我们的服务器被外星人劫持了</li>
            </ul>
        </div>
        
        <div class="notfound-reason">
            <p align="center"><a href="https://m.heimaoba.top/">黑猫之家</a>
            <p align="center"><a href="https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=xfkhy5h5">阿里云优惠券</a>
            <p align="center"><a href="https://www.bt.cn/?invite_code=MV9za2l1eW8=">宝塔专业版优惠券</a>
        </div>

    </div></body>
</html>


文/黑猫之家

来黑猫之家看看呗

Copyright © 2021-2023 | 个人技术展示 |赣ICP备18005425号-1 | 赣公网安备36070202000869 |