centos 7 linuxを使用してngrokを独自に構築し、イントラネットの貫通を実現

5384 ワード

一、環境設置
インストールgit yumのプログラムが見つからない場合、または遅い場合は、このチュートリアルyumに移動してプログラムが見つからない場合は、yumは国内アリソースを交換してください
#   git         
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++  

#      git (     https://www.kernel.org/pub/software/scm/git/)  
cd /usr/local  
wget https://www.kernel.org/pub/software/scm/git/git-2.16.2.tar.gz  

#     
tar zxvf git-2.16.2.tar.gz  

#   git  
cd git-2.16.2  
./configure --prefix=/usr/local/git  
make  
make install  

#       git 
cd /usr/local
rm git-2.16.2.tar.gz -y

インストールgo
#   go 
cd /usr/local
www.golangtc.com/static/go   (     ,            ,linux-amd64 64  。linux-386 32  )
wget https://www.golangtc.com/static/go/1.9.2/go1.9.2.linux-amd64.tar.gz  
    ,       ,       

#     
tar -zxvf go1.9.2.linux-amd64.tar.gz /usr/local/  

# go          /usr/bin  
ln -s /usr/local/go/bin/* /usr/bin/ 

#     go 
rm go1.9.2.linux-amd64.tar.gz -y

go環境設定
#  go       
yum install mercurial bzr subversion -y
#  go        
mkdir -p $HOME/go
# cat            golang  GOROOT GOPATH
#(  ,  GOROOT        go     ,             ,      )
    ,        
cat >>$HOME/.bash_profile<

二、ngrok配置
ダウンロードngrok
cd /usr/local/  
git clone https://github.com/inconshreveable/ngrok.git

かんきょうへんすう
export GOPATH=/usr/local/ngrok/  
export NGROK_DOMAIN="xxx.com"   #         ,    ,  www

他の人の家がngrokであることに疑問があると思います.xxx.comはこのような形式のここで3級のドメイン名の解析を使って、もしあなたがxxxを使いたいならば.ngrok.xxx.comという最終的なドメイン名形式であなたのサービスにアクセスします(ここで初めて構築したのはお勧めではありません.2級が成功したら3級を使うことができますが、環境変数からこのステップで再操作しなければなりません).次のチュートリアルを見てください.
超単純図解三級ドメイン名解析
証明書の生成
cd /usr/local/ngrok
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 

コピー証明書ngrok元の証明書を上書き
       y   
cp rootCA.pem assets/client/tls/ngrokroot.crt 
cp server.crt assets/server/tls/snakeoil.crt 
cp server.key assets/server/tls/snakeoil.key

サービス・エンドの生成
cd /usr/local/ngrok/  
GOOS=linux GOARCH=amd64 make release-server  #  GOOS       ,  linux,GOARCH      ,64  amd64,32  386
         ,     ,    。
        ,       。
       /usr/local/ngrok/bin       ngrokd  

エラー:cannot install cross-compiled binariesをクロスコンパイルできません
$ make release-server GOOS=linux GOARCH=386  
bin/go-bindata -nomemcopy -pkg=assets -tags=release \  
        -debug=false \  
        -o=src/ngrok/client/assets/assets_release.go \  
        assets/client/...  
bin/go-bindata -nomemcopy -pkg=assets -tags=release \  
        -debug=false \  
        -o=src/ngrok/server/assets/assets_release.go \  
        assets/server/...  
go get -tags 'release' -d -v ngrok/...  
go install -tags 'release' ngrok/main/ngrokd  
go install: cannot install cross-compiled binaries when GOBIN is set  
make: *** [server] Error 1

解決策
cd /usr/local/ngrok
mkdir bin  
cp $GOBIN/go-bindata bin/  
unset GOBIN

クライアントの生成
cd /usr/local/ngrok/  
GOOS=windows GOARCH=amd64 make release-client  #  GOOS       ,    window      ,GOARCH      ,64  amd64,32  386
         ,     ,    。
    /usr/local/ngrok/bin/windows_amd64   ngrok.exe  
  bin ,    ngrokd       ngrok

サーバ側の起動
           80   ,     80       ,       。
     ,    nginx     ngrok。

cd /usr/local/ngrok/bin
ngrokd -domain="xxx.com" -httpAddr=":80" -httpsAddr=":8081" -tunnelAddr=":4443"

#-domain           -httpAddr http    -httpsAddr https    
#-tunnerlAddr      ,    

クライアントの起動(window)
ここでngrok.exeは自分のパソコンにダウンロードし、ディレクトリの下にファイルngrokを作成します.conf;内容は次のとおりです.
server_addr: "xxxx.com:4443"   #         
trust_host_root_certs: false  

#        
ngrok -config=./ngrok.conf -subdomain=blog 80 
#  subdomain          ,    ,
#                 

起動batスクリプトの作成
::     ngrok.exe      
::    
::            
:: -config        
:: -subdomain            (   )
:: 8080             (    )  
::F:\WeiChat
grok
grok -config=ngrok.cfg -subdomain bianys 8080 ::F:\WeiChat
grok
grok -config=ngrok.cfg -hostname bianys 80 ::ngrok http -config=C:\Users\administrator\.ngrok2
grok.yml @echo OFF color 0a Title Ngrok by ThinkiveWeixin :START ECHO. Echo===================================================== ECHO. Echo Ngrok ... ECHO. Echo===================================================== .
grok.exe -config=ngrok.cfg -subdomain xxxx 127.0.0.1:8080 PAUSE goto TUNNEL

この文書は次のとおりです.https://segmentfault.com/a/1190000014094827