Migrate accounts API proxy to openresty
This commit is contained in:
@@ -3,29 +3,24 @@
|
||||
# Recipe:: nginx_api
|
||||
#
|
||||
|
||||
include_recipe "kosmos-nginx"
|
||||
domain = node["akkounts_api"]["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_akkounts_api.erb"
|
||||
owner "www-data"
|
||||
mode 0640
|
||||
tls_cert_for domain do
|
||||
auth "gandi_dns"
|
||||
action :create
|
||||
end
|
||||
|
||||
openresty_site domain do
|
||||
template "nginx_conf_akkounts_api.erb"
|
||||
variables domain: domain,
|
||||
upstream_port: node["akkounts"]["port"],
|
||||
upstream_hosts: upstream_hosts,
|
||||
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
|
||||
|
||||
@@ -6,7 +6,7 @@ upstream _akkounts_api {
|
||||
}
|
||||
|
||||
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 %>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user