#
# Cookbook Name:: kosmos_rsk
# Recipe:: nginx
#

include_recipe "kosmos-nginx"

app_name = "rskj"
domain   = node[app_name]["nginx"]["domain"]

nginx_certbot_site domain

template "#{node['nginx']['dir']}/sites-available/#{domain}" do
  source "nginx_conf_#{app_name}.erb"
  owner 'www-data'
  mode 0640
  variables app_name: app_name,
            domain: domain,
            port: "4444",
            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
