M
M
Mikhail Popov2019-01-28 12:32:10
Nginx
Mikhail Popov, 2019-01-28 12:32:10

How to configure nginx proxying of requests according to the table of correspondences?

I have 2 Apache servers: a_1 and a_2
There is a correspondence table
Server | Address
a_1 | 1
a_1 | 2
a_1 | 3
a_2 | 4
a_2 | 5
a_2 | 6
At the front, the address looks like this:
/a/1
, where a is the server attribute
, 1 is the page address
How to make nginx redirect to the required apache when specifying the page address.
The number of apache servers and pages varies, but it is known exactly from the correspondence table on which of the servers which page is located.
The same page cannot be located on different servers.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
chupasaurus, 2019-01-28
@chupasaurus

Sketch, not checked for validity.

server {
  map $uri $apache_host {
  ~ ^/a/1 a_1
  ~ ^/a/2 a_1
  ~ ^/a/3 a_1
  ~ ^/a/4 a_2
  ~ ^/a/5 a_2
  ~ ^/a/6 a_2
  }
  if ($apache_host) {
    proxy_pass $apache_host;
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question