In computer networks, a reverse proxy is a type of proxy server that retrieves resources on behalf of a client from one or more servers.
These resources are then returned to the client as though they originated from the server itself (or servers themselves).
While a forward proxy acts as an intermediary for its (usually nearby) associated client(s) and returns to them resources accessible on the Internet,
a reverse proxy acts as an intermediary for its (usually nearby) associated server(s) and only returns resources provided by those associated server(s).
反向代理Reverse Proxy
1) 代理服务器的概念proxy server:
代理服务器 的概念很容易理解,就是通常作为两台机器中间的机器,需要提供的功能往往有:
- 缓存caching,
- 安全,
- 负载均衡load banlancing。
所谓的负载均衡就是,很多机器使用一个代理的时候,代理服务器需要对各个服务器进行均衡。
我们常见的代理是正向的代理,例如我们机房有20台电脑要上网,现在只有一个电脑可以上网,那么可以使用这台电脑作为代理服务器,所有通过网络的数据传输 都要经过该代理服务器。
而反向代理,是和正向代理相反的 ,正向代理针对服务接收方用户来说,反向代理或者叫做服务器端代理是针对服务器端的,意思是有多台服务器,反向代理服务器对用户的请求代理发送给其中的一 台服务器进行处理。
Proxy server :http://en.wikipedia.org/wiki/Proxy_server
2) 实际中对于一个大型网站,我们通常使用很多台sever来构成一个cluster来对用户的各种请求进行响应。因此通常需要一台或者多台反向代理服务器来对多台Server进行服务。
这个反向代理服务器需要提供的功能一般都包括:
- 安全方面;
- 缓存压缩功能;
- 负载均衡 功能;
Reverse proxy :http://en.wikipedia.org/wiki/Reverse_proxy
(需要注意反向代理服务器和防火墙优点类似,但是防火墙一般只有安全方面的考虑,没有缓存和负载均衡方面的功能。)
3) 综上,实际中Web服务器端的架构
通常是多台Web服务器运行并行地提 供服务;
同时还需要在Web服务器前段部署一台或者多台反向代理服务器,一方面缓存一些静态数据,或者将Web服务器动态产生的一些内容缓存,另一方面通过负载均衡功能,可以均匀地将用户的并发请求传递给多台Web服务器进行处理。
这样一方面可以大大降低后面每台Web服务器的负担;另一方 面可以实现多台服务器的负载均衡。