S
S
Stanislav Smirnov2016-08-17 14:39:06
linux
Stanislav Smirnov, 2016-08-17 14:39:06

How to make nginx proxy_pass to another server?

Dear, please tell me how to do this using nginx:
1. Public server
server subnet:
2. Server No. 1
3. Server No. 2
Server No. 1 is available at "public_server.ru/"
Server No. 2 is available at "" public_server.ru/ location"
Approximately according to this scheme, you need to display the server in the public.
There is a proxy_pass in the nzhniks, I found all sorts of such functions on the Internet:

location /name/ {
    proxy_pass http://127.0.0.1/remote/;
}

I didn't figure out how to put it all together. I don't know where to enter all this, how to enter everything. Either in the main config, or in the host one, in what form. Please tell me with examples, as chewed as possible. Thank you very much, all the best!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Cool Admin, 2016-08-17
@squard72

Tax. See.
The nginx config structure is quite simple.
The main level is a file. It stores a certain set of settings, one can be included (included) from the other. There is the first file from which reading of all configuration begins.
The second level is the context or section of the config file. This is a certain area that will be affected by those settings that are inside. The context is indicated by "{}". The main contexts you care about are server and location
The third level of abstraction is the parameters themselves.
In your case, you need to insert two locales into the context of your server and make a proxy pass in each of them

server {
    location / {
        proxy_pass http://server1/;
    }

    location /location2/ {
       proxy_pass http://server2/;
    }
}

Find in your configs the place where the root directory of the site is described, comment out this place and instead paste my config, with editing resp. parameters.
In general, there is a wonderful documentation in Russian with examples.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question