美文网首页
ngrok 服务端安装

ngrok 服务端安装

作者: ucfjepl | 来源:发表于2017-05-22 22:58 被阅读0次

    文档中的命令不要一次执行多个,防止出现不必要的错误

    1. 安装依赖

    yum -y install zlib-devel openssl-devel perl hg cpio expat-devel gettext-devel curl curl-devel perl-ExtUtils-MakeMaker hg wget gcc gcc-c++
    
    1. 下载git

    cd /tools/
    wget https://www.kernel.org/pub/software/scm/git/git-2.6.0.tar.gz
    
    1. 解压git

    tar -zxvf git-2.6.0.tar.gz
    
    1. 编译git

    cd git-2.6.0
    ./configure --prefix=/usr/local/git
    make
    make install
    
    1. 创建git软连接

    ln -s /usr/local/git/bin/* /usr/bin/
    
    1. 下载go

    cd /tools/
    wget http://www.golangtc.com/static/go/1.4.2/go1.4.2.linux-386.tar.gz
    
    1. 解压go

    tar -zxvf go1.4.2.linux-386.tar.gz
    mv go /usr/local/
    
    1. 建立go软连接

    ln -s /usr/local/go/bin/* /usr/bin/
    
    1. 获取ngrok

    cd /tools
    wget https://github.com/inconshreveable/ngrok/archive/1.7.1.zip
    tar -zxvf ngrok-1.7.1.tar.gz
    mv ngrok-1.7.1 ngrok
    mv ngrok /usr/local/src/ngrok/
    export GOPATH=/usr/local/src/ngrok/
    export NGROK_DOMAIN="域名"
    cd ngrok
    
    1. 生成证书

    openssl genrsa -out rootCA.key 2048
    openssl req -x509 -new -nodes -key rootCA.key -subj "/CN=$NGROK_DOMAIN" -days 5000 -out rootCA.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 rootCA.pem -CAkey rootCA.key -CAcreateserial -out server.crt -days 5000
    
    1. 拷贝证书

    cp rootCA.pem assets/client/tls/ngrokroot.crt
    cp server.crt assets/server/tls/snakeoil.crt
    cp server.key assets/server/tls/snakeoil.key
    
    1. 国内服务器需要执行此修改操作

    vim /usr/local/src/ngrok/src/ngrok/log/logger.go
    log "github.com/keepeye/log4go"
    
    1. 编译服务端

    cd /usr/local/go/src
    GOOS=linux GOARCH=amd64 ./make.bash
    cd /usr/local/src/ngrok/
    GOOS=linux GOARCH=amd64 make release-server
    
    1. 编译mac 客户端

    cd /usr/local/go/src
    GOOS=darwin GOARCH=amd64 ./make.bash
    cd /usr/local/src/ngrok/
    GOOS=darwin GOARCH=amd64 make release-client
    
    1. 编译windows 客户端

    cd /usr/local/go/src
    GOOS=windows GOARCH=amd64 ./make.bash
    cd /usr/local/src/ngrok/
    GOOS=windows GOARCH=amd64 make release-client
    
    1. 编译linux 客户端

    cd /usr/local/go/src
    GOOS=linux GOARCH=amd64 ./make.bash
    cd /usr/local/src/ngrok/
    GOOS=linux GOARCH=amd64 make release-client
    
    1. 启动服务

    /usr/local/src/ngrok/bin/ngrokd -domain="$NGROK_DOMAIN" -httpAddr=":80"
    
    1. 客户端配置文件 ngrok.cfg

    server_addr: "域名:4443"
    trust_host_root_certs: false
    
    1. 客户端使用

    ./ngrok -config=./ngrok.cfg -subdomain=blog 80
    setsid ./ngrok -config=./ngrok.cfg -subdomain=test 80 #在linux下如果想后台运行
    

    原文中有问题,已做修改。

    相关文章

      网友评论

          本文标题:ngrok 服务端安装

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