Commit 7c3353f3 by Feanil Patel

Externalize the rate limiting settings to vars.

parent 38658080
...@@ -144,6 +144,11 @@ EDXAPP_LMS_PREVIEW_NGINX_PORT: 18020 ...@@ -144,6 +144,11 @@ EDXAPP_LMS_PREVIEW_NGINX_PORT: 18020
EDXAPP_CMS_NGINX_PORT: 18010 EDXAPP_CMS_NGINX_PORT: 18010
EDXAPP_CMS_SSL_NGINX_PORT: 48010 EDXAPP_CMS_SSL_NGINX_PORT: 48010
# NGINX Rate limiting related vars
EDXAPP_ENABLE_RATE_LIMITING: true
EDXAPP_COURSE_REQUEST_RATE: '5r/s'
EDXAPP_COURSE_REQUEST_BURST_RATE: 10
EDXAPP_LANG: 'en_US.UTF-8' EDXAPP_LANG: 'en_US.UTF-8'
EDXAPP_LANGUAGE_CODE : 'en' EDXAPP_LANGUAGE_CODE : 'en'
EDXAPP_TIME_ZONE: 'America/New_York' EDXAPP_TIME_ZONE: 'America/New_York'
......
...@@ -10,8 +10,10 @@ upstream lms-backend { ...@@ -10,8 +10,10 @@ upstream lms-backend {
{% endfor %} {% endfor %}
} }
{%- if EDXAPP_ENABLE_RATE_LIMITING -%}
# Make Zone # Make Zone
limit_req_zone $cookie_{{ EDXAPP_SESSION_COOKIE_NAME }} zone=cookies:10m rate=1r/s; limit_req_zone $cookie_{{ EDXAPP_SESSION_COOKIE_NAME }} zone=cookies:10m rate={{ EDXAPP_COURSES_REQUEST_RATE }};
{%- endif -%}
server { server {
# LMS configuration file for nginx, templated by ansible # LMS configuration file for nginx, templated by ansible
...@@ -72,9 +74,12 @@ server { ...@@ -72,9 +74,12 @@ server {
} }
location /courses { location /courses {
{%- if EDXAPP_ENABLE_RATE_LIMITING -%}
# Set Limit # Set Limit
limit_req zone=cookies burst=3; limit_req zone=cookies burst={{ EDXAPP_COURSE_REQUEST_BURST_RATE }};
{% include "basic-auth.j2" %} {%- endif -%}
{%- include "basic-auth.j2" %}
try_files $uri @proxy_to_lms_app; try_files $uri @proxy_to_lms_app;
} }
......
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