G
G
Ghash2017-02-02 23:33:20
Nginx
Ghash, 2017-02-02 23:33:20

Is it really possible to make a project according to the scheme, where the frontend works on Node.JS, and the backend on php?

Please tell me, is it really possible to make a project according to the scheme, where the front-end works on Node.JS, and the back-end on php? If - yes, then how to build a competent server architecture. If we put Nginx (proxy) + Node.JS, then it turns out that Node.JS works as a backend. Thanks in advance!

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Dmitry MiksIr, 2017-02-03
@Ghash

As already mentioned, a node is also a backend. They are used together by separating requests to the node and php by url or server name.
For example, by url. Requests like /api/something/ go to php, all other requests go to the node. Those. the client request comes to nginx, it redirects it to the node, it works out the logic and makes a request to nginx to /api/something/, which, using the location rules, redirects it to php.
On the domain - it is similar. It's just that in nginx there will be different server blocks for different types of requests with their own site_name (and, possibly, their own listen, if we want to spread these entry points to different ports or ip addresses). If the request is to www.domain.com - a request to a node. If the request is to localhost - a request to php. Accordingly, the node makes requests to localhost (also through nginx).
Theoretically, a node can work directly with PHP without an intermediate nginx, using the FastCGI protocol, but this scheme is almost never used. And due to the fact that it is easier to work from a node with http, and because of the much greater flexibility of configuration management, while the additional overhead from yes nginx between the node and php is very small relative to the total request processing time.

D
Dark Hole, 2017-02-02
@abyrkov

Node.js is always Backend.

M
malbaron, 2017-02-02
@malbaron

The frontend is the interaction with the user on the client computer. In the browser.
NodeJS is not needed there.
If you are talking about the fact that on the NodeJS client (no browser!!!!) , and on the PHP server - yes, it is possible.
But applying the word "frontend" to NodeJS in this case would be incorrect.
It is more correct to call NodeJS a client, a client application.

A
Anton Bobylev, 2017-02-02
@dpigo

Well, if you have phantom.zhs as a browser) "Frontend" works in the browser, somehow.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question