反向代理Reverse proxy

https://www.zhihu.com/question/24723688/answer/160252724

反向代理
在計算機世界裏,因爲單個服務器的處理客戶端(用戶)請求能力有一個極限,當用戶的接入請求蜂擁而入時,會形成服務器忙不過來的局面,可使用多個服務器來共同分擔成千上萬的用戶請求,這些服務器提供相同的服務,對於用戶來講,根本感受不到任何差異。
javascript

 

反向代理的實現
1)須要有一個負載均衡設備來分發用戶請求,將用戶請求分發到空閒的服務器上php

2)服務器返回本身的服務到負載均衡設備html

3)負載均衡將服務器的服務返回用戶java

以上的潛臺詞是:用戶和負載均衡設備直接通訊,也意味着用戶作服務器域名解析時,解析獲得的IP實際上是負載均衡的IP,而不是服務器的IP,這樣有一個好處是,當新加入/移走服務器時,僅僅須要修改負載均衡的服務器列表,而不會影響現有的服務。python



 https://en.wikipedia.org/wiki/Reverse_proxy

反向代理的主要做用爲:jquery

對客戶端隱藏伺服器(叢集)的IP位址
安全:做爲應用層防火牆,爲網站提供對基於Web的攻擊行爲(例如DoS/DDoS)的防禦,更容易排查惡意軟體等
爲後端伺服器(叢集)統一提供加密和SSL加速(如SSL終端代理)
負載均衡,若伺服器叢集中有負荷較高者,反向代理經過URL重寫,根據連線請求從負荷較低者獲取與所需相同的資源或備援
對於靜態內容及短期內有大量存取請求的動態內容提供快取服務
對一些內容進行壓縮,以節約頻寬或爲網路頻寬不佳的網路提供服務
減速上傳
爲在私有網路下(如區域網路)的伺服器叢集提供NAT穿透及外網發佈服務
提供HTTP存取認證[2]
突破互聯網封鎖(不經常使用,由於反向代理與客戶端之間的連線不必定是加密連線,非加密連線仍有遭內容審查進而遭封禁的風險;此外面對針對網域名稱的關鍵字過濾、DNS快取污染/投毒攻擊乃至深度封包檢測也無能爲力)ios

 
 

Difference between proxy server and reverse proxy server

The previous answers were accurate, but perhaps too terse. I will try to add some examples.nginx

First of all, the word "proxy" describes someone or something acting on behalf of someone else.web

In the computer realm, we are talking about one server acting on the behalf of another computer.apache

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 site Z.

      • 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 blocked X.

      • 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.
  • 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.

In the above scenarios, Z has the ability to choose Y.

Links to topics from the post:

Content Delivery Network

forward proxy software (server side)

reverse proxy software for HTTP (server side)

reverse proxy software for TCP (server side)

see also:

相關文章
相關標籤/搜索