Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
configuration
Commits
bd3cc376
Commit
bd3cc376
authored
Dec 21, 2015
by
Arbab Nazar
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2594 from edx/arbab/ops-1208
OPS-1208 Refactor Nginx SSL redirect bahavior
parents
2bff4f65
57ee6985
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
112 additions
and
90 deletions
+112
-90
playbooks/roles/nginx/defaults/main.yml
+1
-0
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/cms.j2
+21
-18
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/ecommerce.j2
+21
-18
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/insights.j2
+13
-9
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/lms-preview.j2
+13
-9
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/lms.j2
+20
-19
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/programs.j2
+22
-17
util/jenkins/ansible-provision.sh
+1
-0
No files found.
playbooks/roles/nginx/defaults/main.yml
View file @
bd3cc376
...
...
@@ -11,6 +11,7 @@ NGINX_EDXAPP_EXTRA_CONFIGS: []
NGINX_EDXAPP_CUSTOM_REDIRECTS
:
{}
NGINX_ENABLE_SSL
:
False
NGINX_REDIRECT_TO_HTTPS
:
False
# Set these to real paths on your
# filesystem, otherwise nginx will
# use a self-signed snake-oil cert
...
...
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/cms.j2
View file @
bd3cc376
...
...
@@ -30,18 +30,36 @@ server {
error_page {{ k }} {{ v }};
{% endfor %}
listen {{ EDXAPP_CMS_NGINX_PORT }} {{ default_site }};
{% if NGINX_ENABLE_SSL %}
listen {{ EDXAPP_CMS_NGINX_PORT }} {{ default_site }};
listen {{ EDXAPP_CMS_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";
{% endif %}
{% else %}
listen {{ EDXAPP_CMS_NGINX_PORT }} {{ default_site }};
{% if NGINX_REDIRECT_TO_HTTPS %}
# Redirect http to https over single instance
if ($scheme != "https")
{
set $do_redirect_to_https "true";
}
# Nginx does not support nested conditions
# 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";
}
if ($do_redirect_to_https = "true")
{
rewrite ^ https://$host$request_uri? permanent;
}
{% endif %}
server_name {{ CMS_HOSTNAME }};
...
...
@@ -91,19 +109,4 @@ error_page {{ k }} {{ v }};
{% include "robots.j2" %}
{% include "static-files.j2" %}
{% if NGINX_SET_X_FORWARDED_HEADERS %}
if ($scheme != "https") {
rewrite ^ https://$host$uri permanent;
}
{% else %}
# Forward to HTTPS if we're an HTTP request...
if ($http_x_forwarded_proto = "http") {
set $do_redirect "true";
}
# Run our actual redirect...
if ($do_redirect = "true") {
rewrite ^ https://$host$request_uri? permanent;
}
{% endif %}
}
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/ecommerce.j2
View file @
bd3cc376
...
...
@@ -18,18 +18,36 @@ upstream ecommerce_app_server {
server {
server_name {{ ECOMMERCE_HOSTNAME }};
listen {{ ECOMMERCE_NGINX_PORT }} {{ default_site }};
{% if NGINX_ENABLE_SSL %}
listen {{ ECOMMERCE_NGINX_PORT }} {{ default_site }};
listen {{ ECOMMERCE_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";
{% endif %}
{% else %}
listen {{ ECOMMERCE_NGINX_PORT }} {{ default_site }};
{% if NGINX_REDIRECT_TO_HTTPS %}
# Redirect http to https over single instance
if ($scheme != "https")
{
set $do_redirect_to_https "true";
}
# Nginx does not support nested conditions
# 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";
}
if ($do_redirect_to_https = "true")
{
rewrite ^ https://$host$request_uri? permanent;
}
{% endif %}
location ~ ^/static/(?P<file>.*) {
...
...
@@ -53,20 +71,5 @@ location @proxy_to_app {
proxy_pass http://ecommerce_app_server;
}
{% if NGINX_SET_X_FORWARDED_HEADERS %}
if ($scheme != "https") {
rewrite ^ https://$host$uri permanent;
}
{% else %}
# Forward to HTTPS if we're an HTTP request...
if ($http_x_forwarded_proto = "http") {
set $do_redirect "true";
}
# Run our actual redirect...
if ($do_redirect = "true") {
rewrite ^ https://$host$request_uri? permanent;
}
{% endif %}
}
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/insights.j2
View file @
bd3cc376
...
...
@@ -33,18 +33,22 @@ location @proxy_to_app {
proxy_pass http://insights_app_server;
}
{% if NGINX_SET_X_FORWARDED_HEADERS %}
if ($scheme != "https") {
rewrite ^ https://$host$uri permanent;
{% if NGINX_REDIRECT_TO_HTTPS %}
# Redirect http to https over single instance
if ($scheme != "https")
{
set $do_redirect_to_https "true";
}
{% else %}
# Forward to HTTPS if we're an HTTP request...
if ($http_x_forwarded_proto = "http") {
set $do_redirect "true";
# Nginx does not support nested conditions
# 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";
}
# Run our actual redirect...
if ($do_redirect = "true")
{
if ($do_redirect_to_https = "true")
{
rewrite ^ https://$host$request_uri? permanent;
}
{% endif %}
...
...
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/lms-preview.j2
View file @
bd3cc376
...
...
@@ -76,18 +76,22 @@ server {
expires epoch;
}
{% if NGINX_SET_X_FORWARDED_HEADERS %}
if ($scheme != "https") {
rewrite ^ https://$host$uri permanent;
{% if NGINX_REDIRECT_TO_HTTPS %}
# Redirect http to https over single instance
if ($scheme != "https")
{
set $do_redirect_to_https "true";
}
{% else %}
# Forward to HTTPS if we're an HTTP request...
if ($http_x_forwarded_proto = "http") {
set $do_redirect "true";
# Nginx does not support nested conditions
# 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";
}
# Run our actual redirect...
if ($do_redirect = "true")
{
if ($do_redirect_to_https = "true")
{
rewrite ^ https://$host$request_uri? permanent;
}
{% endif %}
...
...
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/lms.j2
View file @
bd3cc376
...
...
@@ -51,19 +51,35 @@ server {
error_page {{ k }} {{ v }};
{% endfor %}
listen {{ EDXAPP_LMS_NGINX_PORT }} {{ default_site }};
{% if NGINX_ENABLE_SSL %}
listen {{ EDXAPP_LMS_NGINX_PORT }} {{ default_site }};
listen {{ EDXAPP_LMS_SSL_NGINX_PORT }} {{ default_site }} 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";
{% endif %}
{% else %}
listen {{ EDXAPP_LMS_NGINX_PORT }} {{ default_site }};
{% if NGINX_REDIRECT_TO_HTTPS %}
# Redirect http to https over single instance
if ($scheme != "https")
{
set $do_redirect_to_https "true";
}
# Nginx does not support nested conditions
# 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";
}
if ($do_redirect_to_https = "true")
{
rewrite ^ https://$host$request_uri? permanent;
}
{% endif %}
access_log {{ nginx_log_dir }}/access.log {{ NGINX_LOG_FORMAT_NAME }};
...
...
@@ -185,19 +201,4 @@ location ~ ^{{ EDXAPP_MEDIA_URL }}/(?P<file>.*) {
{% include "robots.j2" %}
{% include "static-files.j2" %}
{% if NGINX_SET_X_FORWARDED_HEADERS %}
if ($scheme != "https") {
rewrite ^ https://$host$uri permanent;
}
{% else %}
# Forward to HTTPS if we're an HTTP request...
if ($http_x_forwarded_proto = "http") {
set $do_redirect "true";
}
# Run our actual redirect...
if ($do_redirect = "true") {
rewrite ^ https://$host$request_uri? permanent;
}
{% endif %}
}
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/programs.j2
View file @
bd3cc376
...
...
@@ -18,9 +18,10 @@ upstream programs_app_server {
server {
server_name {{ PROGRAMS_HOSTNAME }};
listen {{ PROGRAMS_NGINX_PORT }} {{ default_site }};
{% if NGINX_ENABLE_SSL %}
listen {{ PROGRAMS_NGINX_PORT }} {{ default_site }};
listen {{ PROGRAMS_SSL_NGINX_PORT }} ssl;
ssl_certificate /etc/ssl/certs/{{ NGINX_SSL_CERTIFICATE|basename }};
...
...
@@ -28,8 +29,26 @@ server {
# Request that the browser use SSL for all connections.
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
{% else %}
listen {{ PROGRAMS_NGINX_PORT }} {{ default_site }};
{% endif %}
{% if NGINX_REDIRECT_TO_HTTPS %}
# Redirect http to https over single instance
if ($scheme != "https")
{
set $do_redirect_to_https "true";
}
# Nginx does not support nested conditions
# 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";
}
if ($do_redirect_to_https = "true")
{
rewrite ^ https://$host$request_uri? permanent;
}
{% endif %}
location ~ ^/static/(?P<file>.*) {
...
...
@@ -61,19 +80,5 @@ location @proxy_to_app {
proxy_redirect off;
proxy_pass http://programs_app_server;
}
{% if NGINX_SET_X_FORWARDED_HEADERS %}
if ($scheme != "https") {
rewrite ^ https://$host$uri permanent;
}
{% else %}
# Forward to HTTPS if we're an HTTP request...
if ($http_x_forwarded_proto = "http") {
set $do_redirect "true";
}
# Run our actual redirect...
if ($do_redirect = "true") {
rewrite ^ https://$host$request_uri? permanent;
}
{% endif %}
}
util/jenkins/ansible-provision.sh
View file @
bd3cc376
...
...
@@ -174,6 +174,7 @@ COURSE_DISCOVERY_SSL_NGINX_PORT: 443
COURSE_DISCOVERY_VERSION:
$course_discovery_version
NGINX_SET_X_FORWARDED_HEADERS: True
NGINX_REDIRECT_TO_HTTPS: True
EDX_ANSIBLE_DUMP_VARS: true
migrate_db: "yes"
openid_workaround: True
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment