D
D
Dimash Kenzhegaliev2021-06-05 13:05:41
Nginx
Dimash Kenzhegaliev, 2021-06-05 13:05:41

How to deploy back and front on the same server?

hello, I’m already so tired, I don’t understand what to do,
please help,
I need to deploy the front written in vue and the back on node express
, as a result, I need the front to be available at https://example.com
and the back at https ://api.example.com
I have already installed nginx, pm2 downloaded my repository, configured ssh key
, but I don’t know how to configure nginx for all this, I want everything to work through one ecosystem.js file, but this is not necessary,
I I see that you need to somehow translate localhost:3000 to the back, that is, api.example.com,
and localhost:8080 to the front, that is, example.com,
I have already registered and linked the domain and subdomain,
I beg you to help, otherwise I have been trying to do this for 3 days in a row and nothing happens

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
ky0, 2021-06-05
@Giranda22-Git

Everything is within the framework of the standard configuration with proxying. You make two server blocks, separate them on different ports in proxy_pass.

K
Karpion, 2021-06-05
@Karpion

Depending on where d.b. front and back are available, you can come up with different solutions.
The easiest way is to separate the front and back to different IP addresses, since you can take more than enough of them from the 127.*.*.* pool. And then you need to run two instances of Ngnix at these addresses. And register each address in DNS in the corresponding zone.
If the front and back should be accessible from the outside, from all over the world - for this scheme, you need to have several IP addresses.
You can separate the front and back to different ports. Then in DNS, both names should point to the same IP address, and the port should. registered in the URL.
And finally, you can make DNS-based virtual hosts (virt. sites) inside one Ngnix. In DNS, both names must point to the same IP address.
PS: You can also put the front and back in different virtual machines, and it will be as if they are on different computers.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question