Add JSON log format to openresty

This commit is contained in:
Râu Cao 2023-07-26 11:50:24 +02:00
parent 507a812f33
commit 4b08e4fc8c
Signed by: raucao
GPG Key ID: 15E65F399D084BA9
2 changed files with 18 additions and 10 deletions

View File

@ -11,7 +11,10 @@
} }
}, },
"openresty": { "openresty": {
"listen_ip": "148.251.237.111" "listen_ip": "148.251.237.111",
"log_formats": {
"json": "{\"ip\":\"$remote_addr\",\"time\":\"$time_local\",\"host\":\"$host\",\"method\":\"$request_method\",\"uri\":\"$uri\",\"status\":$status,\"size\":$body_bytes_sent,\"referer\":\"$http_referer\",\"upstream_addr\":\"$upstream_addr\",\"upstream_response_time\":\"$upstream_response_time\",\"ua\":\"$http_user_agent\"}"
}
} }
}, },
"automatic": { "automatic": {
@ -21,24 +24,27 @@
"hostname": "draco", "hostname": "draco",
"ipaddress": "148.251.237.73", "ipaddress": "148.251.237.73",
"roles": [ "roles": [
"base",
"kvm_host",
"openresty_proxy", "openresty_proxy",
"openresty" "openresty"
], ],
"recipes": [ "recipes": [
"kosmos-base", "kosmos-base",
"kosmos-base::default", "kosmos-base::default",
"kosmos_encfs",
"kosmos_encfs::default",
"kosmos_kvm::host", "kosmos_kvm::host",
"kosmos_kvm::backup", "kosmos_kvm::backup",
"kosmos-ejabberd::firewall",
"kosmos-ipfs::firewall_swarm",
"kosmos-bitcoin::firewall",
"kosmos_zerotier::firewall",
"kosmos_openresty", "kosmos_openresty",
"kosmos_openresty::default", "kosmos_openresty::default",
"kosmos_openresty::firewall", "kosmos_openresty::firewall",
"kosmos_assets::nginx_site", "kosmos_assets::nginx_site",
"kosmos-akkounts::nginx",
"kosmos_encfs",
"kosmos_encfs::default",
"kosmos-ejabberd::firewall",
"kosmos-ipfs::firewall_swarm",
"kosmos-bitcoin::firewall",
"kosmos_zerotier::firewall",
"sockethub::firewall", "sockethub::firewall",
"apt::default", "apt::default",
"timezone_iii::default", "timezone_iii::default",
@ -54,7 +60,6 @@
"postfix::_attributes", "postfix::_attributes",
"postfix::sasl_auth", "postfix::sasl_auth",
"hostname::default", "hostname::default",
"firewall::default",
"openresty::apt_package", "openresty::apt_package",
"openresty::ohai_plugin", "openresty::ohai_plugin",
"openresty::commons_user", "openresty::commons_user",
@ -65,7 +70,8 @@
"openresty::luarocks", "openresty::luarocks",
"git::default", "git::default",
"git::package", "git::package",
"kosmos-base::letsencrypt" "kosmos-base::letsencrypt",
"firewall::default"
], ],
"platform": "ubuntu", "platform": "ubuntu",
"platform_version": "20.04", "platform_version": "20.04",
@ -85,12 +91,12 @@
"run_list": [ "run_list": [
"role[base]", "role[base]",
"role[kvm_host]", "role[kvm_host]",
"role[openresty_proxy]",
"recipe[kosmos_encfs]", "recipe[kosmos_encfs]",
"recipe[kosmos-ejabberd::firewall]", "recipe[kosmos-ejabberd::firewall]",
"recipe[kosmos-ipfs::firewall_swarm]", "recipe[kosmos-ipfs::firewall_swarm]",
"recipe[kosmos-bitcoin::firewall]", "recipe[kosmos-bitcoin::firewall]",
"recipe[kosmos_zerotier::firewall]", "recipe[kosmos_zerotier::firewall]",
"role[openresty_proxy]",
"recipe[sockethub::firewall]" "recipe[sockethub::firewall]"
] ]
} }

View File

@ -3,5 +3,7 @@
# Recipe:: default # Recipe:: default
# #
node.normal['openresty']['log_formats']['json'] = '{"ip":"$remote_addr","time":"$time_local","host":"$host","method":"$request_method","uri":"$uri","status":$status,"size":$body_bytes_sent,"referer":"$http_referer","upstream_addr":"$upstream_addr","upstream_response_time":"$upstream_response_time","ua":"$http_user_agent"}'
# Install openresty from official packages # Install openresty from official packages
include_recipe 'openresty::apt_package' include_recipe 'openresty::apt_package'