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
OpenEdx
configuration
Commits
a6149ea5
Commit
a6149ea5
authored
9 years ago
by
Edward Zarecor
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2682 from edx/e0d/nginx-redirect-to-ssl
SSL Redirect rationalization
parents
86f9cb6d
4ba79e36
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
125 additions
and
8 deletions
+125
-8
playbooks/roles/nginx/defaults/main.yml
+4
-0
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/analytics_api.j2
+26
-0
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/cms.j2
+7
-1
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/ecommerce.j2
+7
-3
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/edx_notes_api.j2
+26
-0
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/insights.j2
+7
-1
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/kibana.j2
+26
-0
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/lms-preview.j2
+8
-1
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/lms.j2
+7
-1
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/programs.j2
+7
-1
No files found.
playbooks/roles/nginx/defaults/main.yml
View file @
a6149ea5
...
@@ -21,6 +21,10 @@ NGINX_REDIRECT_TO_HTTPS: False
...
@@ -21,6 +21,10 @@ NGINX_REDIRECT_TO_HTTPS: False
#
#
# cat www.example.com.crt bundle.crt > www.example.com.chained.crt
# cat www.example.com.crt bundle.crt > www.example.com.chained.crt
# This variable is only checked if NGINX_REDIRECT_TO_HTTPS is true
# It should be set to one of !!null, "scheme" or "forward_for_proto"
NGINX_HTTPS_REDIRECT_STRATEGY
:
"
scheme"
NGINX_SSL_CERTIFICATE
:
'
ssl-cert-snakeoil.pem'
NGINX_SSL_CERTIFICATE
:
'
ssl-cert-snakeoil.pem'
NGINX_SSL_KEY
:
'
ssl-cert-snakeoil.key'
NGINX_SSL_KEY
:
'
ssl-cert-snakeoil.key'
...
...
This diff is collapsed.
Click to expand it.
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/analytics_api.j2
View file @
a6149ea5
...
@@ -7,6 +7,32 @@ upstream analytics_api_app_server {
...
@@ -7,6 +7,32 @@ upstream analytics_api_app_server {
server {
server {
listen {{ ANALYTICS_API_NGINX_PORT }} default_server;
listen {{ ANALYTICS_API_NGINX_PORT }} default_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";
}
{% endif %}
{% if 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 %}
location ~ ^/static/(?P<file>.*) {
location ~ ^/static/(?P<file>.*) {
root {{ COMMON_DATA_DIR }}/{{ analytics_api_service_name }};
root {{ COMMON_DATA_DIR }}/{{ analytics_api_service_name }};
try_files /staticfiles/$file =404;
try_files /staticfiles/$file =404;
...
...
This diff is collapsed.
Click to expand it.
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/cms.j2
View file @
a6149ea5
...
@@ -42,20 +42,26 @@ error_page {{ k }} {{ v }};
...
@@ -42,20 +42,26 @@ error_page {{ k }} {{ v }};
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
{% endif %}
{% endif %}
# 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_REDIRECT_TO_HTTPS %}
{% if NGINX_HTTPS_REDIRECT_STRATEGY == "scheme" %}
# Redirect http to https over single instance
# Redirect http to https over single instance
if ($scheme != "https")
if ($scheme != "https")
{
{
set $do_redirect_to_https "true";
set $do_redirect_to_https "true";
}
}
{% endif %}
{% if NGINX_HTTPS_REDIRECT_STRATEGY == "forward_for_proto" %}
# Nginx does not support nested conditions
# Forward to HTTPS if we're an HTTP request... and the server is behind ELB
# Forward to HTTPS if we're an HTTP request... and the server is behind ELB
if ($http_x_forwarded_proto = "http")
if ($http_x_forwarded_proto = "http")
{
{
set $do_redirect_to_https "true";
set $do_redirect_to_https "true";
}
}
{% endif %}
# Execute the actual redirect
if ($do_redirect_to_https = "true")
if ($do_redirect_to_https = "true")
{
{
rewrite ^ https://$host$request_uri? permanent;
rewrite ^ https://$host$request_uri? permanent;
...
...
This diff is collapsed.
Click to expand it.
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/ecommerce.j2
View file @
a6149ea5
...
@@ -30,20 +30,24 @@ server {
...
@@ -30,20 +30,24 @@ server {
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
{% endif %}
{% endif %}
# 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_REDIRECT_TO_HTTPS %}
{% if NGINX_HTTPS_REDIRECT_STRATEGY == "scheme" %}
# Redirect http to https over single instance
# Redirect http to https over single instance
if ($scheme != "https")
if ($scheme != "https")
{
{
set $do_redirect_to_https "true";
set $do_redirect_to_https "true";
}
}
{% endif %}
# Nginx does not support nested conditions
{% if NGINX_HTTPS_REDIRECT_STRATEGY == "forward_for_proto" %}
# Forward to HTTPS if we're an HTTP request... and the server is behind ELB
# Forward to HTTPS if we're an HTTP request... and the server is behind ELB
if ($http_x_forwarded_proto = "http")
if ($http_x_forwarded_proto = "http")
{
{
set $do_redirect_to_https "true";
set $do_redirect_to_https "true";
}
}
{% endif %}
# Execute the actual redirect
if ($do_redirect_to_https = "true")
if ($do_redirect_to_https = "true")
{
{
rewrite ^ https://$host$request_uri? permanent;
rewrite ^ https://$host$request_uri? permanent;
...
...
This diff is collapsed.
Click to expand it.
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/edx_notes_api.j2
View file @
a6149ea5
...
@@ -7,6 +7,32 @@ upstream {{ edx_notes_api_service_name }}_app_server {
...
@@ -7,6 +7,32 @@ upstream {{ edx_notes_api_service_name }}_app_server {
server {
server {
listen {{ edx_notes_api_nginx_port }} default_server;
listen {{ edx_notes_api_nginx_port }} default_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";
}
{% endif %}
{% if 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 %}
location / {
location / {
try_files $uri @proxy_to_app;
try_files $uri @proxy_to_app;
}
}
...
...
This diff is collapsed.
Click to expand it.
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/insights.j2
View file @
a6149ea5
...
@@ -33,20 +33,26 @@ location @proxy_to_app {
...
@@ -33,20 +33,26 @@ location @proxy_to_app {
proxy_pass http://insights_app_server;
proxy_pass http://insights_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_REDIRECT_TO_HTTPS %}
{% if NGINX_HTTPS_REDIRECT_STRATEGY == "scheme" %}
# Redirect http to https over single instance
# Redirect http to https over single instance
if ($scheme != "https")
if ($scheme != "https")
{
{
set $do_redirect_to_https "true";
set $do_redirect_to_https "true";
}
}
{% endif %}
{% if NGINX_HTTPS_REDIRECT_STRATEGY == "forward_for_proto" %}
# Nginx does not support nested conditions
# Forward to HTTPS if we're an HTTP request... and the server is behind ELB
# Forward to HTTPS if we're an HTTP request... and the server is behind ELB
if ($http_x_forwarded_proto = "http")
if ($http_x_forwarded_proto = "http")
{
{
set $do_redirect_to_https "true";
set $do_redirect_to_https "true";
}
}
{% endif %}
# Execute the actual redirect
if ($do_redirect_to_https = "true")
if ($do_redirect_to_https = "true")
{
{
rewrite ^ https://$host$request_uri? permanent;
rewrite ^ https://$host$request_uri? permanent;
...
...
This diff is collapsed.
Click to expand it.
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/kibana.j2
View file @
a6149ea5
...
@@ -23,6 +23,32 @@ server {
...
@@ -23,6 +23,32 @@ server {
listen {{ KIBANA_NGINX_PORT }} {{ default_site }};
listen {{ KIBANA_NGINX_PORT }} {{ default_site }};
{% endif %}
{% endif %}
# 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";
}
{% endif %}
{% if 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 %}
server_name {{ KIBANA_SERVER_NAME }};
server_name {{ KIBANA_SERVER_NAME }};
root {{ kibana_app_dir }}/htdocs;
root {{ kibana_app_dir }}/htdocs;
...
...
This diff is collapsed.
Click to expand it.
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/lms-preview.j2
View file @
a6149ea5
...
@@ -76,23 +76,30 @@ server {
...
@@ -76,23 +76,30 @@ server {
expires epoch;
expires epoch;
}
}
# 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_REDIRECT_TO_HTTPS %}
{% if NGINX_HTTPS_REDIRECT_STRATEGY == "scheme" %}
# Redirect http to https over single instance
# Redirect http to https over single instance
if ($scheme != "https")
if ($scheme != "https")
{
{
set $do_redirect_to_https "true";
set $do_redirect_to_https "true";
}
}
{% endif %}
{% if NGINX_HTTPS_REDIRECT_STRATEGY == "forward_for_proto" %}
# Nginx does not support nested conditions
# Forward to HTTPS if we're an HTTP request... and the server is behind ELB
# Forward to HTTPS if we're an HTTP request... and the server is behind ELB
if ($http_x_forwarded_proto = "http")
if ($http_x_forwarded_proto = "http")
{
{
set $do_redirect_to_https "true";
set $do_redirect_to_https "true";
}
}
{% endif %}
# Execute the actual redirect
if ($do_redirect_to_https = "true")
if ($do_redirect_to_https = "true")
{
{
rewrite ^ https://$host$request_uri? permanent;
rewrite ^ https://$host$request_uri? permanent;
}
}
{% endif %}
{% endif %}
}
}
This diff is collapsed.
Click to expand it.
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/lms.j2
View file @
a6149ea5
...
@@ -62,20 +62,26 @@ error_page {{ k }} {{ v }};
...
@@ -62,20 +62,26 @@ error_page {{ k }} {{ v }};
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
{% endif %}
{% endif %}
# 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_REDIRECT_TO_HTTPS %}
{% if NGINX_HTTPS_REDIRECT_STRATEGY == "scheme" %}
# Redirect http to https over single instance
# Redirect http to https over single instance
if ($scheme != "https")
if ($scheme != "https")
{
{
set $do_redirect_to_https "true";
set $do_redirect_to_https "true";
}
}
{% endif %}
{% if NGINX_HTTPS_REDIRECT_STRATEGY == "forward_for_proto" %}
# Nginx does not support nested conditions
# Forward to HTTPS if we're an HTTP request... and the server is behind ELB
# Forward to HTTPS if we're an HTTP request... and the server is behind ELB
if ($http_x_forwarded_proto = "http")
if ($http_x_forwarded_proto = "http")
{
{
set $do_redirect_to_https "true";
set $do_redirect_to_https "true";
}
}
{% endif %}
# Execute the actual redirect
if ($do_redirect_to_https = "true")
if ($do_redirect_to_https = "true")
{
{
rewrite ^ https://$host$request_uri? permanent;
rewrite ^ https://$host$request_uri? permanent;
...
...
This diff is collapsed.
Click to expand it.
playbooks/roles/nginx/templates/edx/app/nginx/sites-available/programs.j2
View file @
a6149ea5
...
@@ -31,20 +31,26 @@ server {
...
@@ -31,20 +31,26 @@ server {
{% endif %}
{% endif %}
# 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_REDIRECT_TO_HTTPS %}
{% if NGINX_HTTPS_REDIRECT_STRATEGY == "scheme" %}
# Redirect http to https over single instance
# Redirect http to https over single instance
if ($scheme != "https")
if ($scheme != "https")
{
{
set $do_redirect_to_https "true";
set $do_redirect_to_https "true";
}
}
{% endif %}
{% if NGINX_HTTPS_REDIRECT_STRATEGY == "forward_for_proto" %}
# Nginx does not support nested conditions
# Forward to HTTPS if we're an HTTP request... and the server is behind ELB
# Forward to HTTPS if we're an HTTP request... and the server is behind ELB
if ($http_x_forwarded_proto = "http")
if ($http_x_forwarded_proto = "http")
{
{
set $do_redirect_to_https "true";
set $do_redirect_to_https "true";
}
}
{% endif %}
# Execute the actual redirect
if ($do_redirect_to_https = "true")
if ($do_redirect_to_https = "true")
{
{
rewrite ^ https://$host$request_uri? permanent;
rewrite ^ https://$host$request_uri? permanent;
...
...
This diff is collapsed.
Click to expand it.
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