Commit eb76ae78 by Bilal Ahmad

rebasing and adding necessary comments

parent b649633a
...@@ -15,21 +15,13 @@ upstream lms-backend { ...@@ -15,21 +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 }};
# Iterate through the list of User agent and add limit_req_zone for each user agent
{% for agent in EDXAPP_RATE_LIMITED_USER_AGENTS %} {% for agent in EDXAPP_RATE_LIMITED_USER_AGENTS %}
# Map directive is used in the configuration. Map is used to create a variable # Map of http user agent with name limit_bot_agent_alias having binary IP of the agent
# whose value depends on other variable. So here Map is used actually to
# dynamically have different rate limits for different user agents
map $http_user_agent {{ "$limit_bot_" ~ agent.alias }} { map $http_user_agent {{ "$limit_bot_" ~ agent.alias }} {
{{ agent.agent_name }} $binary_remote_addr; {{ agent.agent_name }} $binary_remote_addr;
} }
# Limit_req_zone for each user agent in EDXAPP_RATE_LIMITED_USER_AGENTS list
limit_req_zone {{ "$limit_bot_" ~ agent.alias }} zone=agents:10m rate={{ agent.rate }}; limit_req_zone {{ "$limit_bot_" ~ agent.alias }} zone=agents:10m rate={{ agent.rate }};
{% endfor %} {% endfor %}
......
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