简体   繁体   中英

Will the request go from Client to backend or from frontend to backend?

So i'm trying to make this architecture (using Spring boot) where the frontend is deployed on a public server (on the internet) and the backend server is deployed on a private server in a private network.
The two servers can communicate via a REST API (no worries as to the communication between those 2).

The frontend server is responsible for displaying the pages to say the least.
While the backend server is responsible for the business logic (eg authentication).

My question is, if a web page (after being displayed on the client machine) sends a request which is supposed to be treated by the backend server (eg http://backend.com/sign-in/ ), will the request ACTUALLY reach the backend (cause somehow the request is actually sent from the frontend server to the backend server) or will it be blocked cause the backend server is inaccessile (cause the request is sent from the client machine to a server on a private network).

PS may the following image help visualize the context.
在此处输入图像描述

If you make a request to http://backend.com/sign-in from the web page (in the browser), it will attempt to send the request directly to that address, so it would get blocked. To reach the backend application, you would have to route the request through the front end application, which would pass it through to the backend. So your browser could make a request to http://frontend.com/sign-in/ which would itself make a call to http://backend.com/sign-in/ and pass it the request body and headers. In this way, the front end application acts as a reverse proxy. I don't know much about Java, but I'm assuming there are some libraries that will handle this for you. Undertow appears to be a possible solution. If you don't want to use your front end application for this, another option would be to set up a simple Nginx reverse proxy that runs either on the same machine or a different public machine that has access to the private server. See this link for help on setting that up.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM