Commit 426d29d4 by Bilal Ahmad

using a map for limit_re_zone directive

parent 391e4e3c
...@@ -282,6 +282,7 @@ EDXAPP_ENABLE_RATE_LIMITING: false ...@@ -282,6 +282,7 @@ EDXAPP_ENABLE_RATE_LIMITING: false
EDXAPP_COURSES_REQUEST_RATE: '5r/s' EDXAPP_COURSES_REQUEST_RATE: '5r/s'
EDXAPP_COURSES_REQUEST_BURST_RATE: 10 EDXAPP_COURSES_REQUEST_BURST_RATE: 10
EDXAPP_COURSES_USER_AGENT_BURST_RATE: 5 EDXAPP_COURSES_USER_AGENT_BURST_RATE: 5
EDXAPP_COURSES_USER_AGENTS: []
EDXAPP_LANG: 'en_US.UTF-8' EDXAPP_LANG: 'en_US.UTF-8'
EDXAPP_LANGUAGE_CODE : 'en' EDXAPP_LANGUAGE_CODE : 'en'
......
...@@ -15,8 +15,13 @@ upstream lms-backend { ...@@ -15,8 +15,13 @@ upstream lms-backend {
# Make Zone # Make Zone
limit_req_zone $cookie_{{ EDXAPP_SESSION_COOKIE_NAME }} zone=cookies:10m rate={{ EDXAPP_COURSES_REQUEST_RATE }}; limit_req_zone $cookie_{{ EDXAPP_SESSION_COOKIE_NAME }} zone=cookies:10m rate={{ EDXAPP_COURSES_REQUEST_RATE }};
{% for agent in EDXAPP_COURSES_USER_AGENTS %} {% for agent in EDXAPP_COURSES_USER_AGENTS %}
limit_req_zone {{ agent.agent_name }} $binary_remote_addr zone=agents:10m rate={{ agent.rate }}; map $http_user_agent {{ "$limit_bot_" ~ agent.alias }} {
{{ agent.agent_name }} $binary_remote_addr;
}
limit_req_zone {{ "$limit_bot_" ~ agent.alias }} zone=agents:10m rate={{ agent.rate }};
{% endfor %} {% endfor %}
{%- endif %}
{%- endif %} {%- endif %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment