Skip to content

Instantly share code, notes, and snippets.

@nginx-gists
Last active November 11, 2022 00:23
Show Gist options
  • Save nginx-gists/62558f37d51ff710798872b086e92f69 to your computer and use it in GitHub Desktop.
Save nginx-gists/62558f37d51ff710798872b086e92f69 to your computer and use it in GitHub Desktop.
NGINX Unit Greets Autumn 2022 with New Features (a Statistics Engine!) and Exciting Plans
{
"action": [
{
"pass": "applications/auth_check"
},
{
"pass": "applications/my_app"
}
]
}
var hellonjs = {}
hellonjs.hello = function(vars) {
if ('unitvar' in vars) {
return vars.unitvar;
} else {
return 'default';
}
}
export default hellonjs
{
"match": {
"uri": "~(?<unitvar>.*)"
},
"action": {
"share": "`/www/html${hellonjs.hello(vars)}`"
}
}
{
"match": {
"uri": "/app/old_path"
},
"action": {
"rewrite": "/app/new_path",
"pass": "routes"
}
}
{
"share": "/www/data/$uri"
}
{
"share": "/path/to/a/file.html"
}
{
"share": "/path/to/dir/"
}
{
"share": [
"/www/$host$uri",
"/www/static$uri",
"/www/app.html"
]
}
{
"share": "/www/data/"
}
{
"share": "/www/data/$host/app.html"
}
{
"connections": {
"accepted": 1067,
"active": 13,
"idle": 4,
"closed": 1050
},
"requests": {
"total": 1307
},
"applications": {
"wp": {
"processes": {
"running": 14,
"starting": 0,
"idle": 4
},
"requests": {
"active": 10
}
}
}
}
{
"action": {
"share": "/www$uri",
"chroot": "/www/data/$host/"
}
}
{
"action": {
"return": 301,
"location": "https://$host$request_uri"
}
}
{
"access_log": {
"path": "/var/log/unit/access.log",
"format": "{ \"remote_addr\":\"$remote_addr\", "time\":\"$time_local\", \"request\":\"$request_line\", \"response\":\"$status\", \"header_referer\":\"$header_referer\", \"header_user_agent\":\"$header_user_agent\" }"
}
}
{
"listeners": {
"*:80": {
"pass": "routes/my-app",
"forwarded": {
"client_ip": "X-Forwarded-For",
"protocol": "X-Forwarded-Proto",
"recursive": false,
"source": [
"198.51.100.1-198.51.100.254",
"!198.51.100.128/26",
"203.0.113.195"
]
}
}
},
...
}
@nginx-gists
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment