Front-end development, often mentioned node server as a reverse proxy, to request background data, but for many front-end developers, just know that there is a word called reverse proxy, and then no and then. The concepts and benefits of reverse proxies are documented here.

concept

In computer networks, a reverse proxy is a type of proxy server. The server obtains resources from one or more groups of its relational back-end servers (such as Web servers) on the request of the client, and then returns these resources to the client, which is only aware of the IP address of the reverse proxy, but not the existence of the server cluster behind the proxy server.

Different from the forward proxy, the forward proxy, as the proxy of the client, returns the resources obtained from the Internet to one or more clients. The server (such as the Web server) only knows the IP address of the proxy but not the IP address of the client. A reverse proxy is used as a proxy on the server side, such as a Web server, rather than as a client. Client borrows by the forward agent can be indirect access to many different Internet servers (cluster) of resources, and the reverse proxy is for many clients through its indirect access different backend server resources, without the need to know the existence of the backend server, and thought that all the resources from the reverse proxy server.

Reverse proxy is not uncommon in the current Internet, and some examples, such as CDN, SNI proxy, are a kind of extended application of reverse proxy combined with DNS.

– a wiki

In fact, the wiki’s description provides a good explanation of what reverse proxy is. If you still don’t know what reverse proxy is, read on.

Forward agent

If there is a reverse proxy, there must be a forward proxy, after all, there is a positive. So what is a forward proxy? Let’s take a real life example: eating out. (Here on the blackboard, the protagonist is Xiao Ming)

  1. Xiao Ming and his friends have an appointment to have dinner (why xiao Ming? No why!) “And then they pick a restaurant and call it restaurant (for no reason! Random!) “, then went inside the restaurant, found a seat and made it to table 7 (no reason, everyone from 1 to 6!).
  2. The waiter came up and asked, What would you like to eat? Xiao Ming and his friends picked boiled fish, ground three fresh and peanuts, the waiter wrote down on the back of the kitchen, to the kitchen said: 7 table! Boiled fish with three fresh and a plate of peanuts! Then the back kitchen started cooking.
  3. The food is good, the waiter brings it up, Xiao Ming and his friends started to eat, after eating, they went back to their homes, the end.

Let’s go back to the process:

  • Xiao Ming does not know where after out, he just want to eat, other need not take care of, like we open Baidu to search information, I just want to see information.
  • The back kitchen just wants to get things done and out, just like the server just wants to get things sent by request.
  • The waiter just wanted to replace the name of xiao Ming’s dish and bring the dish, during which Xiao Ming and the kitchen staff did their own things.

In this case, the waiter is a forward agent. The client (that is, the computer in your hand) requests the server, usually without a proxy, and simply requests it. But if! I want to request www.google.com, he does not give the visit, is xiao Ming shout broke throat, kitchen also can not hear, at this time need a person to replace Xiao Ming go to kitchen, and then replace the kitchen to dish over (of course can not replace), at this time need a forward proxy server instead of Xiao Ming to request Google. That’s what VPN means. You go to a proxy server, and you ask the proxy server to request Google and give you the data. This has the advantage that Google only sees the proxy server, does not know your existence, the back should know.

The reverse proxy

Now for reverse proxies, forget about the xiaoming process, and look at this: cooking. (Here on the blackboard, the protagonist is the kitchen)

  1. Daming goes to a restaurant (why Daming? Xiao Ming has gone home! Go to a restaurant, sit down, call the waiter, order and the waiter takes the order
  2. Xiao Yang in the kitchen got the menu, looked at it, need meat, celery, tomatoes, eggs, meat and celery reported to Lao Wang, said: Lao Wang, celery fried meat.
  3. Then I thought, the kitchen seems to have no tomatoes and eggs, let the waiter said to Daming, there are no these two dishes, then Daming said, then a celery fried meat.
  4. After cooking, bring it to daming for dinner and go home.

Here’s a look:

  • Lao Wang just cooks, like an OSS server (static file storage server), does one thing. Of course, there must be many old wang, that is, many different kinds of servers.
  • Xiao Yang filtered daming’s tomatoes and eggs, which, in a sense, acted as a firewall in the back of the kitchen. Don’t do! Just like the server prevents some intrusions and attacks.
  • Under normal circumstances, Xiao Yang will cook different dishes for different people, which can be understood as load balancing.

The process simplification of reverse proxy can be understood as these. In actual situations, reverse proxy actually has many functions.

At the end

The difference between a forward proxy and a reverse proxy is as follows: A forward proxy is used by a client, while a reverse proxy is used by a server.

Finally, vue configures proxyTable as a reverse proxy to allow your local Node service to access the company’s server interface to meet requests and corresponding requests.