zoukankan      html  css  js  c++  java
  • ng内网

    1.下载

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

    2.升级openssl

    https://blog.csdn.net/weixin_41996632/article/details/103496590

    sudo apt install make gcc
    sudo apt update
    sudo apt upgrade
    
    sudo wget https://www.openssl.org/source/openssl-1.1.1b.tar.gz
    
    tar -zxvf openssl-1.1.1b.tar.gz
    cd openssl-1.1.1b
    
    ./config
    make
    sudo make install
    
    
    vim /etc/ld.so.conf
    
    末尾添加:
    /usr/local/bin
    /usr/local/lib
    /usr/local/ssl
    
    链接器生效:
    sudo ldconfig
    
    
    查看版本
    openssl version
    

    image-20201229095043175

    3.生成证书版本

    openssl genrsa -out base.key 2048   
    openssl req -new -x509 -nodes -key base.key -days 10000 -subj "/CN=47.107.174.163" -out base.pem     
    openssl genrsa -out server.key 2048	
    openssl req -new -key server.key -subj "/CN=47.107.174.163" -out server.csr	
    echo subjectAltName = IP:47.107.174.163 > extfile.cnf    
    openssl x509 -req -in server.csr -CA base.pem -CAkey base.key -CAcreateserial -extfile extfile.cnf -days 10000 -out server.crt
    

    image-20201229095447241

    替换证书:

    cp base.pem assets/client/tls/ngrokroot.crt
    

    编译源码:

    make release-server release-client
    

    由于用的ip地址,所以修改源码:

    找到src/ngrok/server/tunel.go

    			// src/ngrok/server/tunel.go  #89 行
    			// Register for random URL
       			 t.url, err = tunnelRegistry.RegisterRepeat(func() string {
        		 return fmt.Sprintf("%s://%x.%s", protocol, rand.Int31(), vhost)
        		}, t)
    
    

    删掉 【%x.】 【rand.Int31(),】 以及该文件第一行引入的 【math/rand】,重新编译出服务端与客户端即可。

    4.生成win10客户端

    GOOS=windows GOARCH=amd64 make release-client  
    

    生成路径为:ngrok目录下bin/windows_amd64/ngrok.exe

    把他复制到自己的win10

    5.启动服务端

    ./bin/ngrokd -tlsKey=server.key -tlsCrt=server.crt -domain="47.107.174.163" -httpAddr=":88" -httpsAddr=":443"    
    

    image-20201229095631579

    端口被占用无伤大雅,换一个就是!

    domain =xx.xx.xx.xx为ip或域名,httpAddr、httpsAddr 分别是 ngrok 用来转发 http、https 服务的端口,可以随意指定。

    ngrokd 还会开一个 4443 端口用来跟客户端通讯(可通过 -tunnelAddr=”:xxx” 指定)

    6.客户端操作

    新建ngrok.cfg

    server_addr: "47.107.174.163:4443"  
    trust_host_root_certs: false  
    

    新建startup.bat

    ngrok -config=ngrok.cfg -log=ngrok.log  8080 
    

    双击bat文件,运行!成功!

    image-20201210144515527

    为了做演示,把本地8080端口,也就是tomcat服务开启。

    随便放首歌进去:

    image-20201210144655630

    访问47.107.174.163:88/examples/Taylor Swift - august.flac

    访问成功~

    image-20201210144837748

  • 相关阅读:
    ES6 Promise 对象及解决回调地狱问题
    ES6 Iterator迭代器和for...of循环
    ES6 Reflect反射
    ES6 Proxy代理
    ES6 Map对象与Set对象
    端口隔离的应用场景与配置
    交换机级联,堆叠,集群技术介绍
    OSPF虚连接简单配置
    小结ospf基本配置的三个参数
    静态路由配置的3个参数
  • 原文地址:https://www.cnblogs.com/ufoo/p/14205704.html
Copyright © 2011-2022 走看看