反向代理Reverse proxy
https://www.zhihu.com/question/24723688/answer/160252724
反向代理
在计算机世界里,由于单个服务器的处理客户端(用户)请求能力有一个极限,当用户的接入请求蜂拥而入时,会造成服务器忙不过来的局面,可以使用多个服务器来共同分担成千上万的用户请求,这些服务器提供相同的服务,对于用户来说,根本感觉不到任何差别。
反向代理的实现
1)需要有一个负载均衡设备来分发用户请求,将用户请求分发到空闲的服务器上
2)服务器返回自己的服务到负载均衡设备
3)负载均衡将服务器的服务返回用户
以上的潜台词是:用户和负载均衡设备直接通信,也意味着用户做服务器域名解析时,解析得到的IP其实是负载均衡的IP,而不是服务器的IP,这样有一个好处是,当新加入/移走服务器时,仅仅需要修改负载均衡的服务器列表,而不会影响现有的服务。
https://en.wikipedia.org/wiki/Reverse_proxy
反向代理的主要作用为:
对客户端隐藏伺服器(丛集)的IP位址
安全:作为应用层防火牆,为网站提供对基于Web的攻击行爲(例如DoS/DDoS)的防护,更容易排查恶意软体等
为后端伺服器(丛集)统一提供加密和SSL加速(如SSL终端代理)
负载均衡,若伺服器丛集中有负荷较高者,反向代理通过URL重写,根据连线请求从负荷较低者获取与所需相同的资源或备援
对于静态内容及短时间内有大量存取请求的动态内容提供快取服务
对一些内容进行压缩,以节约频宽或为网路频宽不佳的网路提供服务
减速上传
为在私有网路下(如区域网路)的伺服器丛集提供NAT穿透及外网发布服务
提供HTTP存取认证[2]
突破互联网封锁(不常用,因为反向代理与客户端之间的连线不一定是加密连线,非加密连线仍有遭内容审查进而遭封禁的风险;此外面对针对网域名称的关键字过滤、DNS快取污染/投毒攻击乃至深度封包检测也无能为力)
Difference between proxy server and reverse proxy server
The previous answers were accurate, but perhaps too terse. I will try to add some examples.
First of all, the word "proxy" describes someone or something acting on behalf of someone else.
In the computer realm, we are talking about one server acting on the behalf of another computer.
For the purposes of accessibility, I will limit my discussion to web proxies - however, the idea of a proxy is not limited to websites.
FORWARD proxy
Most discussion of web proxies refers to the type of proxy known as a "forward proxy."
The proxy event, in this case, is that the "forward proxy" retrieves data from another web site on behalf of the original requestee.
A tale of 3 computers (part I)
For an example, I will list three computers connected to the internet.
- X = your computer, or "client" computer on the internet
- Y = the proxy web site, proxy.example.org
- Z = the web site you want to visit, www.example.net
Normally, one would connect directly from X --> Z.
However, in some scenarios, it is better for Y --> Z
on behalf of X
, which chains as follows: X --> Y --> Z
.
Reasons why X would want to use a forward proxy server:
Here is a (very) partial list of uses of a forward proxy server.
1) X is unable to access Z directly because
a) Someone with administrative authority over
X
's internet connection has decided to block all access to siteZ
.Examples:
The Storm Worm virus is spreading by tricking people into visiting
familypostcards2008.com
, so the system administrator has blocked access to the site to prevent users from inadvertently infecting themselves.Employees at a large company have been wasting too much time on
facebook.com
, so management wants access blocked during business hours.A local elementary school disallows internet access to the
playboy.com
website.A government is unable to control the publishing of news, so it controls access to news instead, by blocking sites such as
wikipedia.org
. See TOR or FreeNet.
b) The administrator of
Z
has blockedX
.Examples:
The administrator of Z has noticed hacking attempts coming from X, so the administrator has decided to block X's IP address (and/or netrange).
Z is a forum website.
X
is spamming the forum. Z blocks X.
REVERSE proxy
A tale of 3 computers (part II)
For this example, I will list three computers connected to the internet.
- X = your computer, or "client" computer on the internet
- Y = the reverse proxy web site, proxy.example.com
- Z = the web site you want to visit, www.example.net
Normally, one would connect directly from X --> Z.
However, in some scenarios, it is better for the administrator of Z
to restrict or disallow direct access and force visitors to go through Y first. So, as before, we have data being retrieved by Y --> Z
on behalf of X
, which chains as follows: X --> Y --> Z
.
What is different this time compared to a "forward proxy," is that this time the user X
does not know he is accessing Z
, because the user X
only sees he is communicating with Y
.
The server Z
is invisible to clients and only the reverse proxy Y
is visible externally. A reverse proxy requires no (proxy) configuration on the client side.
The client X
thinks he is only communicating with Y
(X --> Y
), but the reality is that Y
forwarding all communication (X --> Y --> Z
again).
Reasons why Z would want to set up a reverse proxy server:
- 1) Z wants to force all traffic to its web site to pass through Y first.
- a) Z has a large web site that millions of people want to see, but a
single web server cannot handle all the traffic. So Z sets up many
servers and puts a reverse proxy on the internet that will send users to
the server closest to them when they try to visit Z. This is part of
how the Content Distribution Network (CDN) concept works.- Examples:
- Apple Trailers uses Akamai
- Jquery.com hosts its javascript files using CloudFront CDN (sample).
- etc.
- Examples:
- a) Z has a large web site that millions of people want to see, but a
- 2) The administrator of Z is worried about retaliation for content
hosted on the server and does not want to expose the main server
directly to the public.- a) Owners of Spam brands such as "Canadian Pharmacy" appear to have
thousands of servers, while in reality having most websites hosted on
far fewer servers. Additionally, abuse complaints about the spam will
only shut down the public servers, not the main server.
- a) Owners of Spam brands such as "Canadian Pharmacy" appear to have
In the above scenarios, Z
has the ability to choose Y
.
Links to topics from the post:
Content Delivery Network
- Lists of CDNs
forward proxy software (server side)
- PHP-Proxy
- cgi-proxy
- phproxy (discontinued)
- glype
- Internet censorship wiki: List of Web Proxies
- squid (apparently, can also work as a reverse proxy)
reverse proxy software for HTTP (server side)
- apache mod_proxy (can also work as a forward proxy for HTTP)
- nginx (used on hulu.com, spam sites, etc.)
- HAProxy
- lighthttpd
- perlbal (written for livejournal)
- portfusion
- pound
- varnish cache (written by a freebsd kernel guru)
- repose
reverse proxy software for TCP (server side)
- balance
- delegate
- pen
- portfusion
- pure load balancer (web site defunct)
- python director
see also:
反向代理Reverse proxy的更多相关文章
- 正向代理 forward proxy、反向代理 reverse proxy、透明代理 transparent proxy nginx反向代理原理和配置讲解 防止外部客户机获取内部内容服务器的重定向 URL 缓存命中
[大型网站技术实践]初级篇:借助Nginx搭建反向代理服务器 - Edison Chou - 博客园http://www.cnblogs.com/edisonchou/p/4126742.html 图 ...
- 正向代理 forward proxy、反向代理 reverse proxy、透明代理 transparent proxy
https://zh.wikipedia.org/wiki/反向代理 反向代理在计算机网络中是代理服务器的一种.服务器根据客户端的请求,从其关系的一组或多组后端服务器(如Web服务器)上获取资源,然后 ...
- IIS ARR(Application Request Route)与反向代理(Reverse Proxy)
为何要用反向代理? 这里说说我的场景, 我在服务器上假设了SVN(Visual SVN)用的端口是:8080, 而我想通过输入svn.niusys.com就可以访问我的SVN服务器,也就是要通过80端 ...
- nginx实现http反向代理+负载均衡
原理 反向代理:反向代理(reverse proxy)方式是指以代理来接受internet上的连接请求,然后将请求转发给内部网络上的服务器,并将从服务器上得到的结果返回给internet上请求连接的客 ...
- 用nginx做反向代理来访问防外链图片
用nginx做反向代理来访问防外链图片 女儿的博客从新浪搬到wordpress后,发现原来博客上链接的新浪相册的图片都不能访问了,一年的博客内容,一个个去重新上传图片,修正链接也是个大工程.还是得先想 ...
- Nginx学习笔记(反向代理&搭建集群)
一.前言 1.1 大型互联网架构演变历程 1.1.1 淘宝技术 淘宝的核心技术(国内乃至国际的 Top,这还是2011年的数据) 拥有全国最大的分布式 Hadoop 集群(云梯,2000左右节点,24 ...
- 聊聊 Nginx 的反向代理
背景 最近在优化服务基础设施这块,正好有时间写一下Nginx的体会.相信大家都听说过反向代理,一提到反向代理一定会想到Nginx.什么你没听过Nginx?那么你一定听说过Apache吧!Apache是 ...
- 配置 Nginx 反向代理 WebSocket
用Nginx给网站做反向代理和负载均衡是广泛使用的一种Web服务器部署技术.不仅能够保证后端服务器的隐蔽性,还可以提高网站部署灵活性. 今天我们来讲一下,如何用Nginx给WebSocket服务器实现 ...
- linux之反向代理,反向代理实例,负载均衡实例
目录 nginx反向代理 1. 概述 2. 反向代理服务器的工作原理 (1)作为内容服务器的替身 (2)作为内容服务器的负载均衡器 二. nginx反向代理实例 1.前期准备 2.代理服务器配置 3. ...
随机推荐
- JDK1.8中ArrayList的实现原理及源码分析
一.概述 ArrayList是Java开发中使用比较频繁的一个类,通过对源码的解读,可以了解ArrayList的内部结构以及实现方法,清楚它的优缺点,以便我们在编程时灵活运用. 二.源码分析 2.1 ...
- 2018-2019-2 20175223 实验四 《Android开发基础》实验报告
目录 北京电子科技学院(BESTI)实验报告 实验名称:实验四 Android程序设计 实验内容.步骤与体会: 一.实验四 Android程序设计-1 二.实验四 Android程序设计-2 三.实验 ...
- Selenium:八种元素定位方法
前言: 我们在做WEB自动化时,最根本的就是操作页面上的元素,首先我们要能找到这些元素,然后才能操作这些元素.工具或代码无法像我们测试人员一样用肉眼来分辨页面上的元素.那么我们怎么来定位他们呢? 在学 ...
- mysql学习(1)----------基础语法
进入mysql mysql -u用户名 -p密码 初始用户为root 初始密码为空 status; 查看当前用户,以及数据库的字符集和其他参数的设置 set db characterset= ...
- 转 Page Object模式
Page Object模式是Selenium中的一种测试设计模式,主要是将每一个页面设计为一个Class,其中包含页面中需要测试的元素(按钮,输入框,标题 等),这样在Selenium测试页面中可以通 ...
- Springboot03-异常处理
springboot默认异常处理 Spring Boot提供了一个默认的映射:/error,当处理中抛出异常之后,会转到该请求中处理,并然后返回一个固定的错误页面 统一异常处理 创建全局异常处理类 @ ...
- elementUI table宽度自适应fit
:fit='true' 或者直接为 fit
- picker多级选择器的使用————小程序
picker多级选择器的使用----小程序 picker是选择器来着,既然选择了,就希望可以获取选择的数据. index.html <view>picker获取数据</view> ...
- Codeforces 1188B 式子转化
思路:看到(a + b)想到乘上(a - b)变成平方差展开(并没有想到2333), 两边同时乘上a - b, 最后式子转化成了a ^ 4 - ka = b ^ 4 - kb,剩下的就水到渠成了. 0 ...
- TextView点击后背景颜色、文字颜色改变(转)
转自:http://blog.csdn.net/u013278940/article/details/51152655 TextView本没有点击效果,故为实现点击后文字颜色改变和背景改变,需要写se ...