Migrate accounts API proxy to openresty

This commit is contained in:
Râu Cao
2023-07-26 14:52:37 +02:00
parent 7b5d46c813
commit 842c369d96
4 changed files with 11 additions and 14 deletions

View File

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

View File

@@ -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 %>;