C
C
chelkaz2017-06-21 23:18:24
Bots
chelkaz, 2017-06-21 23:18:24

PHP backend & Javascript frontend How to set up NGINX?

The client will be on JS https://ru.nuxtjs.org
And the API will be on PHP on the same server on the same domain.
How to set up NGINX?
By default, as I understand it, it will generate JS pages, and if the JS router requests at:
/api/*
Then, as I understand it, nginx should send the request to php-fpm ?
Or how is it not?
Maybe fpm is not needed? Maybe somehow locally send a JS router to php?
If possible, post examples of nginx configs for such bundles. I want to poke around and figure it out.

Answer the question

In order to leave comments, you need to log in

6 answer(s)
D
Dimonchik, 2018-11-18
@dimonchik2013

by timer

T
toxa82, 2018-11-18
@toxa82

If I'm not mistaken, then for this you can add a bot to the channel and report the rate through it according to the schedule.

V
Vasily Nazarov, 2017-06-22
@vnaz

You, in principle, have correctly determined everything yourself, just be sure to add versioning of the API (in the future it may very suddenly be very useful):
Do the front as usual, and direct the paths like
site.tld/api/v1/... to PHP

A
Alexander Aksentiev, 2017-06-22
@Sanasol

the usual config that runs php or html.
No super settings needed. There is simply no point.
The page still usually displays the original backend + some kind of backend logic works.
Requests for api, they are on api, nginx seems to be out of business here, the application (backend) analyzes where the request goes.
Well, if the backend is on nodejs and php, then just separate locations or subdomains.
Like two fingers there are configs, ready for your environment, only a psychic will give.

D
davidnum95, 2017-06-22
@davidnum95

The easiest way is to separate the front and back into different domains/subdomains. Let's say the front is site.ru, the back is api.site.ru

D
dk-web, 2019-07-03
@dk-web

chelkaz do not share the config?) unless, of course, after 2 years it is still relevant ... I have already broken my head. And so and so, but something is missing ... I can not run api

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question