Skip to content

Instantly share code, notes, and snippets.

@icarrr
Created July 24, 2022 13:32
Show Gist options
  • Save icarrr/5ddc779308fd60aae53afec914890714 to your computer and use it in GitHub Desktop.
Save icarrr/5ddc779308fd60aae53afec914890714 to your computer and use it in GitHub Desktop.
# NginX conf for micorsite Open edX
server {
access_log /edx/var/log/nginx/your-domain.access.log p_combined;
error_log /edx/var/log/nginx/your-domain.error.log error;
server_name your-domain;
location @proxy_to_lms_app {
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;
proxy_pass http://lms-backend;
}
location / {
try_files $uri @proxy_to_lms_app;
}
location ~ ^/media/(?P<file>.*) {
root /edx/var/edxapp;
try_files /media/$file =404;
}
location ~ ^/static/(?P<file>.*) {
root /edx/var/edxapp;
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;
}
# http://www.red-team-design.com/firefox-doesnt-allow-cross-domain-fonts-by-default
location ~ "/static/(?P<collected>.*\.[0-9a-f]{12}\.(eot|otf|ttf|woff))" {
expires max;
add_header Access-Control-Allow-Origin *;
try_files /staticfiles/$collected /course_static/$collected =404;
}
# 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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment