Bboysoul's Blog

首页 公告 RSS

使用ngrok作反向代理

August 16, 2017 本文有 559 个字 需要花费 2 分钟阅读

简介

自从进入了公司,就碰到一个很大的问题,那就是公司电脑扛不走,所以在家想访问公司的电脑中的资料就很麻烦,所以就只能使用ngrok作反向代理,之后ssh到公司网站去访问电脑里的文件

官网

ngrok.com

操作

首先去官网下载ngrok的二进制文件


请选择对应的平台下载
我的是ubuntu 所以下载的是linux 64 bit
下载完成之后解压
unzip ngrok.zip
你可以执行下面的命令来查看一下使用的命令
./ngrok help

➜  下载 ./ngrok 
NAME:
   ngrok - tunnel local ports to public URLs and inspect traffic

DESCRIPTION:
    ngrok exposes local networked services behinds NATs and firewalls to the
    public internet over a secure tunnel. Share local websites, build/test
    webhook consumers and self-host personal services.
    Detailed help for each command is available with 'ngrok help <command>'.
    Open http://localhost:4040 for ngrok's web interface to inspect traffic.

EXAMPLES:
    ngrok http 80                    # secure public URL for port 80 web server
    ngrok http -subdomain=baz 8080   # port 8080 available at baz.ngrok.io
    ngrok http foo.dev:80            # tunnel to host:port instead of localhost
    ngrok tcp 22                     # tunnel arbitrary TCP traffic to port 22
    ngrok tls -hostname=foo.com 443  # TLS traffic for foo.com to port 443
    ngrok start foo bar baz          # start tunnels from the configuration file

VERSION:
   2.2.8

AUTHOR:
  inconshreveable - <[email protected]>

COMMANDS:
   authtoken	save authtoken to configuration file
   credits	prints author and licensing information
   http		start an HTTP tunnel
   start	start tunnels by name from the configuration file
   tcp		start a TCP tunnel
   tls		start a TLS tunnel
   update	update ngrok to the latest version
   version	print the version string
   help		Shows a list of commands or help for one command

之后申请一个ngrok账号
接着安装authtoken
./ngrok authtoken 你的authtoken
之后就可以作反向代理了
如果你要把自己的80端口代理出去你可以输入下面的命令
./ngrok http 80
接着会显示

ngrok by @inconshreveable                                                           (Ctrl+C to quit)
                                                                                                    
Session Status                online                                                                
Version                       2.2.8                                                                 
Region                        United States (us)                                                    
Web Interface                 http://127.0.0.1:4040                                                 
Forwarding                    http://ddaa40f6.ngrok.io -> localhost:80                              
Forwarding                    https://ddaa40f6.ngrok.io -> localhost:80                             
                                                                                                    
Connections                   ttl     opn     rt1     rt5     p50     p90                           
                              0       0       0.00    0.00    0.00    0.00                          
                                                                                                    
                                                                                

你只要访问对应的比如http://ddaa40f6.ngrok.io这个域名就可以访问自己80端口的网站了,其他的大同小异


Tags:

本站总访问量 本站总访客数