D
D
Developer2017-07-02 18:37:24
Nginx
Developer, 2017-07-02 18:37:24

How to set up Nginx (api/static) balancing?

I'm doing a document processing service. I have several servers, some of them are for a highly loaded API service (REST, POST / GET requests), and some are for statics, registration, statistics, control panel, ...
While I'm balancing
just upstream www {
server xx .xx.xx.xx;#weight=2;
server yy.yy.yy.yy;
server zz.zz.zz.zz;
}
It works. But how can I now separate the requests so that the url https://server.name/api requests are distributed between the above servers, and all other requests are distributed to the server with static/registration, to some nnn.nnn.nnn.nnn ?
It would also be nice if it was possible to send POST requests to several shards, and GET requests to other servers.
The question is simple, but I can not properly configure the balancing.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Fixid, 2017-07-02
@samodum

Make a separate location with your proxy_pass for /api
location / {
proxy_pass upsall;
}
location /api/ {
proxy_pass upsapi;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question