Skip to content

Commit

Permalink
Unit: add processing of static gzip assets
Browse files Browse the repository at this point in the history
- routes are renamed to use "pass" for header check
- formatted to compare with output from server
  • Loading branch information
andypost committed May 15, 2024
1 parent 76f8b23 commit 0694d5c
Showing 1 changed file with 183 additions and 113 deletions.
296 changes: 183 additions & 113 deletions docker/unit.json
Original file line number Diff line number Diff line change
@@ -1,115 +1,185 @@
{
"listeners": {
"*:80": {
"pass": "routes"
}
},
"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",
"*~"
]
},
"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/*"
]
},
"action": {
"pass": "applications/drupal/direct"
}
},
{
"match": {
"uri": [
"!/index.php*",
"*.php"
]
},
"action": {
"return": 404
}
},
{
"action": {
"share": "/var/www/html/web$uri",
"fallback": {
"pass": "applications/drupal/index"
}
}
}
],
"applications": {
"drupal": {
"type": "php",
"processes": {
"max": 4,
"spare": 2,
"idle_timeout": 120
},
"limits": {
"timeout": 300,
"requests": 1500
},
"options": {
"admin": {
"memory_limit": "1G",
"opcache.jit_buffer_size": "20M"
}
},
"targets": {
"direct": {
"root": "/var/www/html/web/"
},
"index": {
"root": "/var/www/html/web/",
"script": "index.php"
}
}
}
},
"access_log": "/dev/stdout"
"access_log": "/dev/stdout",
"listeners": {
"*:80": {
"pass": "routes/main"
}
},

"routes": {
"main": [
{
"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
}
},
{
"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": 404
}
},
{
"match": {
"uri": [
"~^.*css_[a-zA-Z0-9-_]+\\.css(?:\\?.*)?$",
"~^.*js_[a-zA-Z0-9-_]+\\.js(?:\\?.*)?$"
],

"headers": [
{
"Accept-Encoding": "*gzip*"
}
]
},

"action": {
"pass": "routes/assets_gz"
}
},
{
"action": {
"share": "/var/www/html/web$uri",
"fallback": {
"pass": "applications/drupal/index"
}
}
}
],

"assets_gz": [
{
"match": {
"headers": [
{
"Accept-Encoding": "*gzip*"
}
]
},

"action": {
"share": "/var/www/html/web${uri}.gz",
"response_headers": {
"Content-Encoding": "gzip"
},

"fallback": {
"pass": "routes/assets"
}
}
},
{
"action": {
"pass": "routes/assets"
}
}
],

"assets": [
{
"action": {
"share": "/var/www/html/web${uri}",
"fallback": {
"pass": "applications/drupal/index"
}
}
}
]
},

"applications": {
"drupal": {
"type": "php",
"stdout": "/dev/stdout",
"stderr": "/dev/stderr",
"processes": {
"max": 4,
"spare": 2,
"idle_timeout": 120
},

"limits": {
"timeout": 300,
"requests": 1500
},

"options": {
"admin": {
"memory_limit": "1G",
"opcache.jit_buffer_size": "20M"
}
},

"targets": {
"direct": {
"root": "/var/www/html/web/"
},

"index": {
"root": "/var/www/html/web/",
"script": "index.php"
}
}
}
}
}

0 comments on commit 0694d5c

Please sign in to comment.