30 lines
		
	
	
		
			778 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			778 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
#
 | 
						|
# Cookbook Name:: kosmos-akkounts
 | 
						|
# Recipe:: nginx
 | 
						|
#
 | 
						|
 | 
						|
app_name = "akkounts"
 | 
						|
domain   = node[app_name]["domain"]
 | 
						|
 | 
						|
tls_cert_for domain do
 | 
						|
  auth "gandi_dns"
 | 
						|
  action :create
 | 
						|
end
 | 
						|
 | 
						|
upstream_hosts = []
 | 
						|
search(:node, "role:akkounts").each do |node|
 | 
						|
  upstream_hosts << node["knife_zero"]["host"]
 | 
						|
end
 | 
						|
upstream_hosts.push("localhost") if upstream_hosts.empty?
 | 
						|
 | 
						|
openresty_site domain do
 | 
						|
  template "nginx_conf_#{app_name}.erb"
 | 
						|
  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"
 | 
						|
end
 |