Building Ngrok for intranet penetration (using Nginx proxy)

Source: Internet
Author: User
Tags subdomain

Background: Previously used Ngrok service hung up

Setting up the Environment Ubuntu Server 16.04 LTS 64-bit

  1. Install Git

    sudo apt-get install build-essential golang mercurial git
  2. Get Source code

    git clone https://github.com/tutumcloud/ngrok.git ngrok
  3. To generate a replacement certificate

    cd ngrokNGROK_DOMAIN="ngrok.itcuc.cc"openssl genrsa -out base.key 2048openssl req -new -x509 -nodes -key base.key -days 10000 -subj "/CN=$NGROK_DOMAIN" -out base.pemopenssl genrsa -out server.key 2048openssl req -new -key server.key -subj "/CN=$NGROK_DOMAIN" -out server.csropenssl x509 -req -in server.csr -CA base.pem -CAkey base.key -CAcreateserial -days 10000 -out server.crtcp base.pem assets/client/tls/ngrokroot.crt
  4. Compile source (Generate client)

    sudo make release-server release-client

    Build a client under Windows

    GOOS=windows GOARCH=amd64 make release-client
  5. Start the service

    sudo ./bin/ngrokd -tlsKey=server.key -tlsCrt=server.crt -domain="ngrok.itcuc.cc" -httpAddr=":8081" -httpsAddr=":8082"
  6. Configure Domain Name resolution

Image.png
  1. Configure Nginx Proxy

    Join in the nginx.conf

    server {        listen 80;        server_name *.ngrok.itcuc.cc ngrok.itcuc.cc;        location / {                        proxy_set_header X-Real-IP $remote_addr;                        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;                        proxy_set_header Host  $http_host:8081;                        proxy_set_header X-Nginx-Proxy true;                        proxy_set_header Connection "";                        proxy_pass      http://127.0.0.1:8081;        }    }

    Reload Nginx

  2. Verifying the installation

    Open the http://ngrok.itcuc.cc/in the browser, if the tunnel ngrok.itcuc.cc:8081 not found means the installation is ready

  3. Installing the Client

    Download the 5th step of the saved Windows client
    Create a new Ngrok configuration file in the same directory, name it casually, for example ngrok.conf
    Adding code to the configuration file

    server_addr: ngrok.itcuc.cc:4443trust_host_root_certs: false

    New bat file, adding code

    cd %cd%ngrok -config=ngrok.cfg -subdomain=wxtest 8080

    Subdomain is the domain name and port you want to use

No more.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.