From 73c9bd81746e714d9855743badd0443c37d69ee3 Mon Sep 17 00:00:00 2001 From: Alexandre Dias Date: Tue, 16 Jun 2020 16:52:51 +0100 Subject: [PATCH] Add more rules to Drupal conf (#146) * add more rules - Drupal * Update src/nginxconfig/generators/conf/drupal.conf.js Co-authored-by: Matt (IPv4) Cowley * Update src/nginxconfig/generators/conf/drupal.conf.js Co-authored-by: Matt (IPv4) Cowley * Update src/nginxconfig/generators/conf/drupal.conf.js Co-authored-by: Matt (IPv4) Cowley * fix rewrite when we can use try_files * Update src/nginxconfig/generators/conf/drupal.conf.js Co-authored-by: Matt (IPv4) Cowley Co-authored-by: Matt (IPv4) Cowley --- src/nginxconfig/generators/conf/drupal.conf.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/nginxconfig/generators/conf/drupal.conf.js b/src/nginxconfig/generators/conf/drupal.conf.js index 96eb397..8613393 100644 --- a/src/nginxconfig/generators/conf/drupal.conf.js +++ b/src/nginxconfig/generators/conf/drupal.conf.js @@ -28,8 +28,9 @@ export default global => { const config = {}; config['# Drupal: deny private files'] = ''; - config['location ~ ^/sites/.*/private/'] = { + config['location ~ ((^|/)\.|^.*\.yml$|^/sites/.*/private/|^/sites/[^/]+/[^/]*settings.*\.php$)'] = { deny: 'all', + return: '404', }; config['# Drupal: deny php in files'] = ''; @@ -42,6 +43,11 @@ export default global => { deny: 'all', }; + config['# Drupal: allow image styles to be handled by the CMS'] = ''; + config['location ~ ^/sites/[^/]+/files/styles/'] = { + try_files: '$uri /index.php?q=$uri&$args', + }; + config['# Drupal: handle private files'] = ''; config['location ~ ^(/[a-z\\-]+)?/system/files/'] = { try_files: '$uri /index.php?$query_string',