From 4b08e4fc8ca3cdbed7bbc2b6d796382de270942b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Wed, 26 Jul 2023 11:50:24 +0200 Subject: [PATCH] Add JSON log format to openresty --- nodes/draco.kosmos.org.json | 26 ++++++++++++------- .../kosmos_openresty/recipes/default.rb | 2 ++ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/nodes/draco.kosmos.org.json b/nodes/draco.kosmos.org.json index 0a933ae..b160e79 100644 --- a/nodes/draco.kosmos.org.json +++ b/nodes/draco.kosmos.org.json @@ -11,7 +11,10 @@ } }, "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": { @@ -21,24 +24,27 @@ "hostname": "draco", "ipaddress": "148.251.237.73", "roles": [ + "base", + "kvm_host", "openresty_proxy", "openresty" ], "recipes": [ "kosmos-base", "kosmos-base::default", - "kosmos_encfs", - "kosmos_encfs::default", "kosmos_kvm::host", "kosmos_kvm::backup", - "kosmos-ejabberd::firewall", - "kosmos-ipfs::firewall_swarm", - "kosmos-bitcoin::firewall", - "kosmos_zerotier::firewall", "kosmos_openresty", "kosmos_openresty::default", "kosmos_openresty::firewall", "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", "apt::default", "timezone_iii::default", @@ -54,7 +60,6 @@ "postfix::_attributes", "postfix::sasl_auth", "hostname::default", - "firewall::default", "openresty::apt_package", "openresty::ohai_plugin", "openresty::commons_user", @@ -65,7 +70,8 @@ "openresty::luarocks", "git::default", "git::package", - "kosmos-base::letsencrypt" + "kosmos-base::letsencrypt", + "firewall::default" ], "platform": "ubuntu", "platform_version": "20.04", @@ -85,12 +91,12 @@ "run_list": [ "role[base]", "role[kvm_host]", + "role[openresty_proxy]", "recipe[kosmos_encfs]", "recipe[kosmos-ejabberd::firewall]", "recipe[kosmos-ipfs::firewall_swarm]", "recipe[kosmos-bitcoin::firewall]", "recipe[kosmos_zerotier::firewall]", - "role[openresty_proxy]", "recipe[sockethub::firewall]" ] } diff --git a/site-cookbooks/kosmos_openresty/recipes/default.rb b/site-cookbooks/kosmos_openresty/recipes/default.rb index d2f6f03..2833b07 100644 --- a/site-cookbooks/kosmos_openresty/recipes/default.rb +++ b/site-cookbooks/kosmos_openresty/recipes/default.rb @@ -3,5 +3,7 @@ # 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 include_recipe 'openresty::apt_package'