Code Monkey home page Code Monkey logo

proxy's Introduction

这款 proxy 呢,可以通过公网服务器访问内网主机,目前仅支持tcp流量转发,是的,需要借助公网服务器,但是不需要把本机的服务部署在公网,这个还是会减少很多工作量的,而且大家也知道,云服务器的资源那是大大的宝贵,当然网上流行的内网穿透,不借助公网服务器,直接穿透内网,以LZ的网络知识,我只想说很难,而且这个在不同的网络环境下影响很大,极大可能性就是不稳定。

proxy 最开始的版本是通过端口转发的,但是这样就需要不同的服务绑定不同的端口,这无疑是一种资源浪费,同时需要开放公网服务器的端口,这样也不好,现在呢可以通过域名转发,同时也可以配合nginx来使用。

工作流程

proxy

上面呢就是proxy的工作模式,很多的代理软件模式都差不多是这样的,代理服务器和代理客户端呢通过私有的协议进行通信。

代理客户端先和代理服务器建立连接,代理服务器通过不同的域名(或端口)来区分具体的代理服务,用户通过访问代理服务器的指定域名(或端口),然后代理服务器将数据转发给代理客户端,客户端再转发数据给真实服务器,当客户端接收到真实服务器响应后,再传输给代理服务器,代理服务器再将数据传送给用户,完成一次请求。

example

(1)通过外网访问本机的mysql

- serverport: 3307
              proxyType: tcp
              realhost: 127.0.0.1
              realhostport: 3306
              description: mysql 代理

配置服务端,将服务端程序运行在公网服务器,同时开放3307端口,本地运行客户端(需要简要配置),这样通过外网ip或者域名访问其3307端口,便是访问内网本机的3306端口了。

20180911152812

(2)ssh 服务

- serverport: 2222
              proxyType: tcp
              realhost: 172.16.254.63
              realhostport: 22
              description: ssh 代理

配置服务端,将服务端程序运行在公网服务器,同时开放2222端口,本地运行客户端(需要简要配置),这样通过外网ip或者域名访问其2222端口,便是访问**内网本机(172.16.254.63)**的22端口了。

TIM截图20180911153744

(3)域名转发

- domain:  proxy.ztgreat.cn
           proxyType: http
           realhost: 127.0.0.1
           realhostport: 8080
           description: http代理

访问proxy.ztgreat.cn 实际访问的便是本机的8080端口

通过域名转发,是共享的同一个端口(非80),这样需要入口配合nginx来使用

代理客户端先和代理服务器建立连接,代理服务器通过不同的端口来区分具体的代理服务,用户通过访问代理服务器的指定端口,然后代理服务器将数据转发给代理客户端,客户端再转发数据给真实服务器,当客户端接收到真实服务器响应后,再传输给代理服务器,代理服务器再将数据传送给用户,完成一次请求。

proxy's People

Contributors

ztgreat avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.