Compare commits

...

3 Commits

Author SHA1 Message Date
Râu Cao
89f5c994a1
Migrate akkounts proxy to openresty 2023-07-26 12:04:36 +02:00
Râu Cao
a2c5483e19
Update openresty cookbook 2023-07-26 12:04:09 +02:00
Râu Cao
9854793ef0
Add JSON log format to openresty 2023-07-26 11:50:24 +02:00
7 changed files with 33 additions and 28 deletions

View File

@ -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",
@ -83,7 +89,9 @@
}
},
"run_list": [
"recipe[kosmos-base]",
"role[base]",
"role[kvm_host]",
"role[openresty_proxy]",
"recipe[kosmos_encfs]",
"recipe[kosmos_kvm::host]",
"recipe[kosmos_kvm::backup]",
@ -91,7 +99,6 @@
"recipe[kosmos-ipfs::firewall_swarm]",
"recipe[kosmos-bitcoin::firewall]",
"recipe[kosmos_zerotier::firewall]",
"role[openresty_proxy]",
"recipe[sockethub::firewall]"
]
}
}

View File

@ -45,6 +45,7 @@ default_run_list = %w(
production_run_list = %w(
role[openresty]
kosmos_assets::nginx_site
kosmos-akkounts::nginx
)
env_run_lists(

View File

@ -7,7 +7,7 @@ long_description 'Installs/configures kosmos-akkounts'
version '0.2.0'
chef_version '>= 18.0'
depends 'kosmos-nginx'
depends 'kosmos_openresty'
depends "kosmos-nodejs"
depends "redisio"
depends "postgresql"

View File

@ -3,11 +3,13 @@
# Recipe:: nginx
#
include_recipe "kosmos-nginx"
app_name = "akkounts"
domain = node[app_name]["domain"]
app_name = "akkounts"
domain = node[app_name]["domain"]
nginx_certbot_site domain
tls_cert_for domain do
auth "gandi_dns"
action :create
end
upstream_hosts = []
search(:node, "role:akkounts").each do |node|
@ -15,10 +17,8 @@ search(:node, "role:akkounts").each do |node|
end
upstream_hosts.push("localhost") if upstream_hosts.empty?
template "#{node['nginx']['dir']}/sites-available/#{domain}" do
source "nginx_conf_#{app_name}.erb"
owner 'www-data'
mode 0640
openresty_site domain do
template "nginx_conf_#{app_name}.erb"
variables port: node[app_name]['port'],
domain: domain,
upstream_port: node["akkounts"]["port"],
@ -26,9 +26,4 @@ template "#{node['nginx']['dir']}/sites-available/#{domain}" do
root_dir: "/opt/#{app_name}/public",
ssl_cert: "/etc/letsencrypt/live/#{domain}/fullchain.pem",
ssl_key: "/etc/letsencrypt/live/#{domain}/privkey.pem"
notifies :reload, 'service[nginx]', :delayed
end
nginx_site domain do
action :enable
end

View File

@ -10,7 +10,7 @@ proxy_cache_path /var/cache/nginx/akkounts levels=1:2
max_size=1g inactive=120m use_temp_path=off;
server {
listen 443 ssl http2;
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl http2;
listen [::]:443 ssl http2;
server_name <%= @domain %>;

View File

@ -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'

@ -1 +1 @@
Subproject commit 867046cbd1e120f7b2cb842114dcc725cdf0c2b2
Subproject commit b31d6b0b01f74179fd035c2dfcc0222f6c0c45c3