S
S
Sakit Aliyev2019-02-22 16:47:12
Nginx
Sakit Aliyev, 2019-02-22 16:47:12

What should be done to redirect all subdomains from a certain level for processing to another server from the main one?

There is a domain and it refers to the server 0.0.0.1 for example
On this server there is such processing of the nodejs application request:

server {
    listen 80;
    server_name *.domain.com;
    location / {
        proxy_pass http://localhost:8080; # Это порт на котором запущено node js приложение
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
    location /api {

    }
}

And there is also a backend project, on another server that responds to the same domain.
How do you go to /api and further (/api/getnews) which is processed by the main server to give the entire request to another server (they are also connected by localhost) ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ky0, 2019-02-22
@sakitaliev

Repeat approximately the same as in your root location, but in the proxy pass change to the desired host port.
Related Reading - How nginx handles requests , location .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question