2023-03-02 18:05:37 +08:00

35 lines
935 B
Ruby

#
# Cookbook Name:: kosmos-akkounts
# Recipe:: nginx
#
include_recipe "kosmos-nginx"
app_name = "akkounts"
domain = node[app_name]["domain"]
nginx_certbot_site domain
upstream_hosts = []
search(:node, "role:akkounts").each do |node|
upstream_hosts << node["knife_zero"]["host"]
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
variables port: node[app_name]['port'],
domain: domain,
upstream_port: node["akkounts"]["port"],
upstream_hosts: upstream_hosts,
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