From 7989ee88d9828dfb8993f65de64e4d28fe1480e7 Mon Sep 17 00:00:00 2001 From: flytreeleft Date: Sun, 2 Sep 2018 12:35:59 +0800 Subject: [PATCH] Enable HTTPS supports for CMS_HOST --- config/nginx/templates/cms.conf.templ | 17 +++++++++++++++-- config/nginx/templates/lms.conf.templ | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/config/nginx/templates/cms.conf.templ b/config/nginx/templates/cms.conf.templ index 4ab21ed..ce94b9d 100644 --- a/config/nginx/templates/cms.conf.templ +++ b/config/nginx/templates/cms.conf.templ @@ -1,7 +1,20 @@ +{% if ACTIVATE_HTTPS %} server { - listen 80; + server_name {{ CMS_HOST }}; + listen 80; + return 301 https://$server_name$request_uri; +} +{% endif %} + +server { + listen {{ "443 ssl" if ACTIVATE_HTTPS else "80" }}; server_name studio.localhost {{ CMS_HOST }}; - + + {% if ACTIVATE_HTTPS %} + ssl_certificate /etc/letsencrypt/live/{{ LMS_HOST }}/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/{{ LMS_HOST }}/privkey.pem; + {% endif %} + # Prevent invalid display courseware in IE 10+ with high privacy settings add_header P3P 'CP="Open edX does not have a P3P policy."'; diff --git a/config/nginx/templates/lms.conf.templ b/config/nginx/templates/lms.conf.templ index a481085..4128242 100644 --- a/config/nginx/templates/lms.conf.templ +++ b/config/nginx/templates/lms.conf.templ @@ -14,7 +14,7 @@ server { ssl_certificate /etc/letsencrypt/live/{{ LMS_HOST }}/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/{{ LMS_HOST }}/privkey.pem; {% endif %} - + # Prevent invalid display courseware in IE 10+ with high privacy settings add_header P3P 'CP="Open edX does not have a P3P policy."';