Commit 81e7f58d by Feanil Patel

Merge pull request #1512 from edx/feanil/nginx_rate_limiting

Feanil/nginx rate limiting
parents ad56d9fe 590bf5f7
......@@ -147,6 +147,11 @@ EDXAPP_LMS_PREVIEW_NGINX_PORT: 18020
EDXAPP_CMS_NGINX_PORT: 18010
EDXAPP_CMS_SSL_NGINX_PORT: 48010
# NGINX Rate limiting related vars
EDXAPP_ENABLE_RATE_LIMITING: false
EDXAPP_COURSE_REQUEST_RATE: '5r/s'
EDXAPP_COURSE_REQUEST_BURST_RATE: 10
EDXAPP_LANG: 'en_US.UTF-8'
EDXAPP_LANGUAGE_CODE : 'en'
EDXAPP_TIME_ZONE: 'America/New_York'
......
......@@ -10,6 +10,11 @@ upstream lms-backend {
{% endfor %}
}
{%- if EDXAPP_ENABLE_RATE_LIMITING -%}
# Make Zone
limit_req_zone $cookie_{{ EDXAPP_SESSION_COOKIE_NAME }} zone=cookies:10m rate={{ EDXAPP_COURSES_REQUEST_RATE }};
{%- endif -%}
server {
# LMS configuration file for nginx, templated by ansible
......@@ -68,6 +73,16 @@ server {
try_files $uri @proxy_to_lms_app;
}
location /courses {
{%- if EDXAPP_ENABLE_RATE_LIMITING -%}
# Set Limit
limit_req zone=cookies burst={{ EDXAPP_COURSE_REQUEST_BURST_RATE }};
{%- endif -%}
{%- include "basic-auth.j2" %}
try_files $uri @proxy_to_lms_app;
}
{% include "robots.j2" %}
{% include "static-files.j2" %}
......
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