drupal-with-nginx
drupal-with-nginx copied to clipboard
Allow access to .txt files from sites/default/files
It seems the default config blocks access to all .txt files for security reasons. However, it would be useful to allow access to .txt files that have been uploaded to sites/default/files. Here's a patch (this doesn't affect protected files under sites/default/files/private):
diff --git a/apps/drupal/drupal.conf b/apps/drupal/drupal.conf
index 2a5a60b..a0d2e23 100644
--- a/apps/drupal/drupal.conf
+++ b/apps/drupal/drupal.conf
@@ -193,6 +193,21 @@ location / {
# }
# }
+ ## .txt files are allowed only from sites/default/files
+ location ~* ^/sites/default/files/.*\.txt {
+ #access_log off;
+ expires 30d;
+ ## No need to bleed constant updates. Send the all shebang in one
+ ## fell swoop.
+ tcp_nodelay off;
+ ## Set the OS file cache.
+ open_file_cache max=3000 inactive=120s;
+ open_file_cache_valid 45s;
+ open_file_cache_min_uses 2;
+ open_file_cache_errors off;
+ }
+
+
## Advanced Help module makes each module provided README available.
location ^~ /help/ {
location ~* ^/help/[^/]*/README\.txt$ {