Skip to content

Instantly share code, notes, and snippets.

@zxhfighter
Created March 14, 2020 02:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zxhfighter/cbbe1d815b9dab8d554498ca6690b11f to your computer and use it in GitHub Desktop.
Save zxhfighter/cbbe1d815b9dab8d554498ca6690b11f to your computer and use it in GitHub Desktop.

正向代理和反向代理

TLDR; 正向代理隐藏真实客户端,反向代理隐藏真实服务端。

正向代理

正向代理服务器代理的是客户端,为客户端收发请求,使真实客户端对服务器不可见。

客户端必须设置正向代理服务器,当然前提是要知道正向代理服务器的IP地址,还有代理程序的端口。

|-------------------|
|   Client1\        |
|   Client2 \ Proxy |-------> Origin Server
|   Client3 /       |
|-------------------|
   Proxy 代理客户端

反向代理

反向代理服务器代理的是服务端,为服务器收发请求,使真实服务器对客户端不可见。

反向代理服务器(俗称网关)经常用于保证内网的安全,也可以提供负载均衡等服务,Nginx 就是常见的反向代理服务器。

|-------------------|     |-------------------|
|   Client1 ------->|     |       / Server 1  |
|   Client2 ------->|---->| Proxy - Server 2  |
|   Client3 ------->|     |       \ Server 3  |
|-------------------|     |-------------------|
                             Proxy 代理服务器
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment