Answer the question
In order to leave comments, you need to log in
How to set limit_req for a subdomain in Nginx?
Greetings.
Please tell me how to set the limit_req rule for a subdomain.
There is an api, which is available at:
mysite.ru/api
and
api.mysite.ru
For mysite.ru/api, I set the limit_req rule, but it doesn’t work for api.mysite.ru.
server {
server_name mysite.ru api.mysite.ru www.mysite.ru;
...
...
location / {
location ~ [^/]\.ph(p\d*|tml)$ {
try_files /does_not_exists @fallback;
}
location / {
try_files /does_not_exists @fallback;
}
location /api {
limit_req zone=req_limit_api burst=1;
try_files /does_not_exists @fallback;
}
}
location @fallback {
proxy_pass http://127.0.0.1:8081;
proxy_redirect http://127.0.0.1:8081 /;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
access_log off;
}
listen ....:443 ssl;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question