Commit a1b75e59 by Clinton Blackburn Committed by Clinton Blackburn

Fixing discovery for sandboxes

ECOM-3877
parent 9cd01744
......@@ -19,6 +19,7 @@
- ecommerce
- programs
- credentials
- discovery
nginx_default_sites:
- lms
- mysql
......@@ -42,6 +43,7 @@
- ecommerce
- programs
- credentials
- discovery
- oauth_client_setup
- role: datadog
when: COMMON_ENABLE_DATADOG
......
#
# {{ ansible_managed }}
#
{% if nginx_default_sites is defined and "discovery" in nginx_default_sites %}
{% set default_site = "default" %}
{% else %}
{% set default_site = "" %}
{% endif %}
upstream discovery_app_server {
{% for host in nginx_discovery_gunicorn_hosts %}
server {{ host }}:{{ discovery_gunicorn_port }} fail_timeout=0;
{% endfor %}
}
server {
server_name {{ DISCOVERY_HOSTNAME }};
{% if NGINX_ENABLE_SSL %}
listen {{ DISCOVERY_NGINX_PORT }} {{ default_site }};
listen {{ DISCOVERY_SSL_NGINX_PORT }} ssl;
ssl_certificate /etc/ssl/certs/{{ NGINX_SSL_CERTIFICATE|basename }};
ssl_certificate_key /etc/ssl/private/{{ NGINX_SSL_KEY|basename }};
# request the browser to use SSL for all connections
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
{% else %}
listen {{ DISCOVERY_NGINX_PORT }} {{ default_site }};
{% endif %}
location ~ ^/static/(?P<file>.*) {
root {{ COMMON_DATA_DIR }}/{{ discovery_service_name }};
try_files /staticfiles/$file =404;
}
location / {
try_files $uri @proxy_to_app;
}
{% include "robots.j2" %}
location @proxy_to_app {
{% if NGINX_SET_X_FORWARDED_HEADERS %}
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-For $remote_addr;
{% else %}
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
proxy_set_header X-Forwarded-Port $http_x_forwarded_port;
proxy_set_header X-Forwarded-For $http_x_forwarded_for;
{% endif %}
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://discovery_app_server;
}
# Nginx does not support nested condition or or conditions so
# there is an unfortunate mix of conditonals here.
{% if NGINX_REDIRECT_TO_HTTPS %}
{% if NGINX_HTTPS_REDIRECT_STRATEGY == "scheme" %}
# Redirect http to https over single instance
if ($scheme != "https")
{
set $do_redirect_to_https "true";
}
{% elif NGINX_HTTPS_REDIRECT_STRATEGY == "forward_for_proto" %}
# Forward to HTTPS if we're an HTTP request... and the server is behind ELB
if ($http_x_forwarded_proto = "http")
{
set $do_redirect_to_https "true";
}
{% endif %}
# Execute the actual redirect
if ($do_redirect_to_https = "true")
{
rewrite ^ https://$host$request_uri? permanent;
}
{% endif %}
}
......@@ -195,6 +195,7 @@ CREDENTIALS_VERSION: $credentials_version
DISCOVERY_NGINX_PORT: 80
DISCOVERY_SSL_NGINX_PORT: 443
DISCOVERY_VERSION: $discovery_version
NGINX_SET_X_FORWARDED_HEADERS: True
NGINX_REDIRECT_TO_HTTPS: True
EDX_ANSIBLE_DUMP_VARS: true
......@@ -288,8 +289,8 @@ CREDENTIALS_LMS_URL_ROOT: "https://${deploy_host}"
CREDENTIALS_DOMAIN: "credentials-${deploy_host}"
CREDENTIALS_URL_ROOT: "http://{{ CREDENTIALS_DOMAIN }}"
CREDENTIALS_SOCIAL_AUTH_REDIRECT_IS_HTTPS: true
COURSE_DISCOVERY_ECOMMERCE_API_URL: "https://ecommerce-${deploy_host}/api/v2"
DISCOVERY_ECOMMERCE_API_URL: "{{ ECOMMERCE_ECOMMERCE_URL_ROOT }}/api/v2"
DISCOVERY_URL_ROOT: "https://discovery-${deploy_host}"
DISCOVERY_SOCIAL_AUTH_REDIRECT_IS_HTTPS: true
......
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