From efcbd606a3f146d5d0903abbc29b19758fb64c12 Mon Sep 17 00:00:00 2001 From: Andy Postnikov Date: Wed, 14 Jun 2023 04:16:11 +0200 Subject: [PATCH] Add support for brotli and gzip assets - needs to improve file mast in assets match - could use better naming for routes --- php81-unit/conf.json | 207 ++++++++++++++++++++++++++++--------------- 1 file changed, 135 insertions(+), 72 deletions(-) diff --git a/php81-unit/conf.json b/php81-unit/conf.json index 17dd8e6..7caf43e 100644 --- a/php81-unit/conf.json +++ b/php81-unit/conf.json @@ -1,87 +1,150 @@ { "listeners": { "*:80": { - "pass": "routes" + "pass": "routes/drupal" } }, - "routes": [ - { - "match": { - "uri": [ - "!*/.well-known/*", - "/vendor/*", - "/core/profiles/demo_umami/modules/demo_umami_content/default_content/*", - "*.engine", - "*.inc", - "*.install", - "*.make", - "*.module", - "*.po", - "*.profile", - "*.sh", - "*.theme", - "*.tpl", - "*.twig", - "*.xtmpl", - "*.yml", - "*/.*", - "*/Entries*", - "*/Repository", - "*/Root", - "*/Tag", - "*/Template", - "*/composer.json", - "*/composer.lock", - "*/web.config", - "*sql", - "*.bak", - "*.orig", - "*.save", - "*.swo", - "*.swp", - "*~" - ] + "routes": { + "drupal": [ + { + "match": { + "uri": [ + "!*/.well-known/*", + "/vendor/*", + "/core/profiles/demo_umami/modules/demo_umami_content/default_content/*", + "*.engine", + "*.inc", + "*.install", + "*.make", + "*.module", + "*.po", + "*.profile", + "*.sh", + "*.theme", + "*.tpl", + "*.twig", + "*.xtmpl", + "*.yml", + "*/.*", + "*/Entries*", + "*/Repository", + "*/Root", + "*/Tag", + "*/Template", + "*/composer.json", + "*/composer.lock", + "*/web.config", + "*sql", + "*.bak", + "*.orig", + "*.save", + "*.swo", + "*.swp", + "*~" + ] + }, + "action": { + "return": 404 + } }, - "action": { - "return": 404 - } - }, - { - "match": { - "uri": [ - "/core/authorize.php", - "/core/install.php", - "/core/modules/statistics/statistics.php", - "~^/core/modules/system/tests/https?\\.php", - "/core/rebuild.php", - "/update.php", - "/update.php/*" - ] + { + "match": { + "uri": [ + "/core/authorize.php", + "/core/install.php", + "/core/modules/statistics/statistics.php", + "~^/core/modules/system/tests/https?\\.php", + "/core/rebuild.php", + "/update.php", + "/update.php/*" + ] + }, + "action": { + "pass": "applications/drupal/direct" + } + }, + { + "match": { + "uri": [ + "!/index.php*", + "*.php" + ] + }, + "action": { + "return": 405 + } + }, + { + "match": { + "uri": [ + "*.css", + "*.js" + ] + }, + "action": { + "pass": "routes/assets_brotli" + } }, - "action": { - "pass": "applications/drupal/direct" + { + "action": { + "share": "/var/www/html/web$uri", + "fallback": { + "pass": "applications/drupal/index" + } + } } - }, - { - "match": { - "uri": [ - "!/index.php*", - "*.php" - ] + ], + "assets_brotli": [ + { + "match": { + "headers": [ + { + "Accept-Encoding": "*br*" + } + ] + }, + "action": { + "share": "/var/www/html/web$uri.br", + "fallback": { + "pass": "routes/assets_gzip" + } + } }, - "action": { - "return": 404 + { + "action": { + "pass": "routes/assets_gzip" + } } - }, - { - "action": { - "share": "/var/www/html/web$uri", - "fallback": { - "pass": "applications/drupal/index" + ], + "assets_gzip": [ + { + "match": { + "headers": [ + { + "Accept-Encoding": "*gzip*" + } + ] + }, + "action": { + "share": [ + "/var/www/html/web$uri.gz", + "/var/www/html/web$uri" + ], + "fallback": { + "return": 404 + } + } + }, + { + "action": { + "share": "/var/www/html/web$uri", + "fallback": { + "return": 404 + } } } - } - ], + ] + }, "applications": { "drupal": { "type": "php",