美文网首页
{ ngrok } 搭建ngrok服务实现内网穿透

{ ngrok } 搭建ngrok服务实现内网穿透

作者: nealma | 来源:发表于2016-08-03 16:08 被阅读0次

    安装依赖(环境:CentOS)

    yum install build-essential golang mercurial git
    

    获取ngrok

    git clone https://github.com/inconshreveable/ngrok.git
    

    生成并替换默认的证书

    NGROK_DOMAIN="YOUR_DOMAIN"
    openssl genrsa -out base.key 2048
    openssl req -new -x509 -nodes -key base.key -days 10000 -subj "/CN=$NGROK_DOMAIN" -out base.pem
    openssl genrsa -out server.key 2048
    openssl req -new -key server.key -subj "/CN=$NGROK_DOMAIN" -out server.csr
    openssl x509 -req -in server.csr -CA base.pem -CAkey base.key -CAcreateserial -days 10000 -out server.crt
    cp base.pem assets/client/tls/ngrokroot.crt
    

    编译

    make release-server release-client
    

    go环境

    #这里要注意go的环境,有问题可求助Google
    
    

    windows

    sudo GOOS=windows GOARCH=386  make  release-client
    

    Mac

    sudo GOOS=darwin GOARCH=amd64 make  release-client
    

    运行服务端

    ./bin/ngrokd -tlsKey=server.key -tlsCrt=server.crt -domain="YOUR_DOMAIN" -httpAddr=":8081" -httpsAddr=":8082"
    

    客户端

    #ngrok.cfg
    server_addr: YOUR_DOMAIN:4443
    trust_host_root_certs: false
    
    #run
    ./ngrok -subdomain es -config=ngrok.cfg 9200
    

    Git升级

    #如果遇到一直卡住不动,查看是不是你的GIt版本太低了,我的是1.7.1,需要升级Git2.2.1
    ##安装依赖
    yum install --skip-broken -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc 
    yum install --skip-broken -y gcc perl-devel perl-ExtUtils-MakeMaker perl-CPAN
    ##如果出问题,升级yum源
    yum upgrade -y --skip-broken
    ##卸载1.7
    yum remove git
    
    ##下载2.2.1并添加到环境变量
    wget https://github.com/git/git/archive/v2.2.1.tar.gz
    tar zxvf v2.2.1.tar.gz
    cd git-2.2.1
    make configure
    ./configure --prefix=/usr/local/git --with-iconv=/usr/local/libiconv
    make all doc
    make install install-doc install-html
    echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
    source /etc/bashrc
    
    ##查看版本号
    git --version
    
    ##遇到问题
    1, line 1: xmlto: command not found
    wget http://cyberelk.net/tim/data/xmlto/stable/xmlto-0.0.18.tar.bz2
    tar xjvf xmlto-0.0.18.tar.bz2
    cd xmlto-0.0.18
    ./configure
    make && make install
    
    2, ...
    
    

    相关文章

      网友评论

          本文标题:{ ngrok } 搭建ngrok服务实现内网穿透

          本文链接:https://www.haomeiwen.com/subject/ydgqsttx.html