2018-09-02 04:35:59 +00:00
|
|
|
{% if ACTIVATE_HTTPS %}
|
2017-07-03 10:39:19 +00:00
|
|
|
server {
|
2018-09-02 04:35:59 +00:00
|
|
|
server_name {{ CMS_HOST }};
|
|
|
|
listen 80;
|
|
|
|
return 301 https://$server_name$request_uri;
|
|
|
|
}
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
server {
|
|
|
|
listen {{ "443 ssl" if ACTIVATE_HTTPS else "80" }};
|
2018-08-05 14:40:51 +00:00
|
|
|
server_name studio.localhost {{ CMS_HOST }};
|
2018-09-02 04:35:59 +00:00
|
|
|
|
|
|
|
{% if ACTIVATE_HTTPS %}
|
|
|
|
ssl_certificate /etc/letsencrypt/live/{{ LMS_HOST }}/fullchain.pem;
|
|
|
|
ssl_certificate_key /etc/letsencrypt/live/{{ LMS_HOST }}/privkey.pem;
|
|
|
|
{% endif %}
|
|
|
|
|
2017-07-03 10:39:19 +00:00
|
|
|
# Prevent invalid display courseware in IE 10+ with high privacy settings
|
|
|
|
add_header P3P 'CP="Open edX does not have a P3P policy."';
|
|
|
|
|
|
|
|
# Nginx does not support nested condition or or conditions so
|
|
|
|
# there is an unfortunate mix of conditonals here.
|
|
|
|
|
2017-07-24 09:32:50 +00:00
|
|
|
client_max_body_size 100M;
|
2017-07-03 10:39:19 +00:00
|
|
|
|
|
|
|
rewrite ^(.*)/favicon.ico$ /static/images/favicon.ico last;
|
|
|
|
|
|
|
|
# Disables server version feedback on pages and in headers
|
|
|
|
server_tokens off;
|
|
|
|
|
2017-07-24 09:32:50 +00:00
|
|
|
location @proxy_to_cms_app {
|
2017-07-03 10:39:19 +00:00
|
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
|
|
proxy_set_header X-Forwarded-Port $server_port;
|
|
|
|
proxy_set_header X-Forwarded-For $remote_addr;
|
|
|
|
proxy_set_header Host $http_host;
|
|
|
|
proxy_redirect off;
|
2018-04-19 19:16:51 +00:00
|
|
|
|
|
|
|
# Docker resolver
|
|
|
|
resolver 127.0.0.11 valid=10s;
|
|
|
|
set $upstream cms;
|
|
|
|
proxy_pass http://$upstream:8000;
|
2017-07-03 10:39:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
location / {
|
2017-07-24 09:32:50 +00:00
|
|
|
try_files $uri @proxy_to_cms_app;
|
2017-07-03 10:39:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
location ~ ^/static/(?P<file>.*) {
|
2018-01-29 16:18:37 +00:00
|
|
|
root /openedx/data/cms;
|
2017-07-03 10:39:19 +00:00
|
|
|
try_files /staticfiles/$file /course_static/$file =404;
|
|
|
|
|
|
|
|
# return a 403 for static files that shouldn't be
|
|
|
|
# in the staticfiles directory
|
|
|
|
location ~ ^/static/(?:.*)(?:\.xml|\.json|README.TXT) {
|
|
|
|
return 403;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Set django-pipelined files to maximum cache time
|
|
|
|
location ~ "/static/(?P<collected>.*\.[0-9a-f]{12}\..*)" {
|
|
|
|
expires max;
|
|
|
|
# Without this try_files, files that have been run through
|
|
|
|
# django-pipeline return 404s
|
|
|
|
try_files /staticfiles/$collected /course_static/$collected =404;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Set django-pipelined files for studio to maximum cache time
|
|
|
|
location ~ "/static/(?P<collected>[0-9a-f]{7}/.*)" {
|
|
|
|
expires max;
|
|
|
|
|
|
|
|
# Without this try_files, files that have been run through
|
|
|
|
# django-pipeline return 404s
|
|
|
|
try_files /staticfiles/$collected /course_static/$collected =404;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Expire other static files immediately (there should be very few / none of these)
|
|
|
|
expires epoch;
|
|
|
|
}
|
|
|
|
}
|