Commit c92f3f81 by Feanil Patel

Add the ability to embargo users based on CIDR blocks.

parent f253d48d
...@@ -104,3 +104,4 @@ nginx_cfg: ...@@ -104,3 +104,4 @@ nginx_cfg:
version_json: "{{ nginx_app_dir }}/versions.json" version_json: "{{ nginx_app_dir }}/versions.json"
NGINX_ROBOT_RULES: [ ] NGINX_ROBOT_RULES: [ ]
NGINX_EDXAPP_EMBARGO_CIDRS: []
...@@ -8,12 +8,29 @@ upstream lms-backend { ...@@ -8,12 +8,29 @@ upstream lms-backend {
{% for host in nginx_lms_gunicorn_hosts %} {% for host in nginx_lms_gunicorn_hosts %}
server {{ host }}:{{ edxapp_lms_gunicorn_port }} fail_timeout=0; server {{ host }}:{{ edxapp_lms_gunicorn_port }} fail_timeout=0;
{% endfor %} {% endfor %}
} }
{%- if EDXAPP_ENABLE_RATE_LIMITING -%} {%- if EDXAPP_ENABLE_RATE_LIMITING -%}
# 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 }};
{%- endif -%} {%- endif %}
{% if NGINX_EDXAPP_EMBARGO_CIDRS %}
{%- if NGINX_SET_X_FORWARDED_HEADERS %}
geo $remote_addr $embargo {
{%- else %}
geo $http_x_forwarded_for $embargo {
{% endif -%}
default 0;
{% for cidr in NGINX_EDXAPP_EMBARGO_CIDRS -%}
{{ cidr }} 1;
{% endfor %}
}
{%- endif %}
server { server {
# LMS configuration file for nginx, templated by ansible # LMS configuration file for nginx, templated by ansible
...@@ -77,8 +94,20 @@ error_page {{ k }} {{ v }}; ...@@ -77,8 +94,20 @@ error_page {{ k }} {{ v }};
location / { location / {
{% include "basic-auth.j2" %} {% include "basic-auth.j2" %}
{% if NGINX_EDXAPP_EMBARGO_CIDRS -%}
if ( $embargo ) {
rewrite ^ /embargo;
}
{% endif -%}
try_files $uri @proxy_to_lms_app;
}
{% if NGINX_EDXAPP_EMBARGO_CIDRS %}
location /embargo {
try_files $uri @proxy_to_lms_app; try_files $uri @proxy_to_lms_app;
} }
{% endif %}
# No basic auth for /segmentio/event # No basic auth for /segmentio/event
location /segmentio/event { location /segmentio/event {
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