Home  >  Q&A  >  body text

httproxy - We usually call Nginx a reverse proxy server, so what is a reverse proxy and what is a forward proxy?

We usually call Nginx a reverse proxy server, so what is a reverse proxy and what is a forward proxy?

淡淡烟草味淡淡烟草味2712 days ago1653

reply all(13)I'll reply

  • 我想大声告诉你

    我想大声告诉你2017-05-16 17:23:59

    A communicates directly with B, which means there is no agency;

    However, there is a messenger C in the middle. C is the agent. A transmits information to B through C, and then C relays B’s feedback to A.

    In this process, A knows that the direct target of communication is B, but due to various reasons it is unable to face B directly and needs an intermediary C. This is the so-called "forward agent". In fact, we rarely talk about forward agency. In the original English text, this is called Forward Proxy. Generally, it is just called proxy. If you translate it as "forwarding proxy" or "transmitting proxy", it is better than "forward proxy". However, it is not necessary, because that is the original meaning of the word proxy.

    Another situation is: A does not know the existence of B. It only knows to find C to get the desired reply. For A, whether there is B or how many B, D, E, F... It doesn't matter, as long as there is C, it is enough. And C gets feedback according to the situation and then responds to A.

    This is called a reverse proxy. To understand the difference, don't focus on the two antonyms of "positive and negative". Forward and Reverse in English are not a pair of antonyms, but Forward and Backward. However, Reverse and Backward do not mean the same thing... so For technical books and materials, you still have to read the original text.

    ─────

    A friend asked me a question just now because he was still confused about it. I gave him an example and he understood. I don’t know if my answer above can make everyone understand, so I also wrote this example:

    Forward Proxy

    I want to access www.google.com, but everyone knows that it is blocked and I cannot access it directly. So I connected to a VPN service and set it as a proxy for local HTTP access (for example, under Mac, check "Send all traffic through the VPN connection), and then I accessed www.google.com, and my request was blocked. The VPN service proxies me access to www.google.com and returns the results to me

    .
    1. This example is an application scenario of the proxy, but it does not mean that the proxy can only be used for this

    2. The most important feature is that I know the existence of www.google.com, and the URL I visited is indeed www.google.com, but my access request is forwarded through a VPN proxy, and the same is true for the response

    3. In this case, the proxy is transparent, and the user may not know its existence (usually he does, but he may not set up the proxy himself)

    Reverse Proxy

    I have an Nginx service deployed on port 80 of www.mysite.com. When users visit it, they can see the website I made; there are some Ajax requests in my website to obtain JSON data, but the API Service that provides these data is deployed Port 8000 on the server is blocked by the firewall and cannot be directly accessed by users.

    So I reconfigured Nginx so that it would proxy all access requests via :80/api/ to localhost:8000, and then return the response to the original requester (ie: Origin Host). This is a reverse proxy. Now my users can access www.mysite.com normally.

    1. Same as above, this is an application scenario of reverse proxy, but it does not mean that it can only be used in this way

    2. The most important feature is that my users don't know the existence of the localhost:8000 service at all, and even if they know it, they can't access it - they can't access it even if they open a VPN, which is two different things!

    3. For users, the only "conversation" party is www.mysite.com (port 80). They don't know and don't need to know what happened next

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-16 17:23:59

    Reverse proxy means that the target behind it is fixed
    Users accessing your nginx is equivalent to accessing the web service behind the proxy

    Forward proxy means that the target of its proxy is not fixed
    Users can access any web service through the proxy server

    reply
    0
  • 阿神

    阿神2017-05-16 17:23:59

    The main difference is whether it is the client or the server acting as a proxy.
    If the client uses a proxy when sending a request, it is a forward proxy;
    And when the server receives the client's request, it uses a proxy to transfer to other servers, which is a reverse proxy;

    reply
    0
  • PHP中文网

    PHP中文网2017-05-16 17:23:59

    Forward proxy: You need to actively set the proxy server IP or domain name for access. Obtain the access content and return it based on the set server IP or domain name.

    Reverse proxy: You don’t need any settings to directly access the server’s real IP or domain name, but the server will automatically jump and return content based on the accessed content. You don’t know which machines it ultimately accesses.

    reply
    0
  • PHP中文网

    PHP中文网2017-05-16 17:23:59

    For the ABC example, the forward agent can be understood as: C goes to B as an agent of A, while C in the reverse agent is more like an agent of B, going to give feedback to A.

    reply
    0
  • ringa_lee

    ringa_lee2017-05-16 17:23:59

    To put it simply, it depends on who you represent. The client's proxy is a forward proxy, and the server's proxy is a reverse proxy

    reply
    0
  • PHP中文网

    PHP中文网2017-05-16 17:23:59

    When the computer accesses the server, and the server does not know the computer’s real IP, there is a forward proxy between the two.

    If the computer accesses the server and the computer does not know the real IP of the server, there is a reverse proxy between the two.

    Of course, many forward proxies can also pass the computer’s real IP through the http head

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-16 17:23:59

    Forward agent: You go to KFC to eat hamburger and chicken wings. The hamburger and chicken wings are obtained from the headquarters through the "agent" sub-centers at each level and then distributed to you.
    Reverse proxy: When KFC headquarters gives you hamburgers and chicken wings, it may first allocate sub-centers in different regions and then go to stores, and finally deliver them to you, but it is transparent to you and you don’t need to know whether it is East China or North China. The branch center will deliver it to you.

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-05-16 17:23:59

    When we go online, we sometimes need to configure a proxy server (such as being blocked). This proxy server is a forward proxy; when developing a server system, the request proxy sent by the client/browser is distributed to multiple real businesses in the background. Server, this proxy is a reverse proxy.

    You can think of the forward proxy as client-side and the reverse proxy as server-side.

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-16 17:23:59

    View /q/1010000003698318?_ea=331448

    reply
    0
  • Cancelreply