2 Commits

Author SHA1 Message Date
Râu Cao
ad59913555 Migrate lndhub proxy to openresty 2023-07-26 15:00:55 +02:00
Râu Cao
1bad2939de Migrate accounts API proxy to openresty 2023-07-26 15:00:43 +02:00
7 changed files with 26 additions and 34 deletions

View File

@@ -38,7 +38,6 @@
"kosmos_openresty::default",
"kosmos_openresty::firewall",
"kosmos_assets::nginx_site",
"kosmos-akkounts::nginx",
"kosmos_discourse::nginx",
"kosmos_drone::nginx",
"kosmos_gitea::nginx",
@@ -46,6 +45,9 @@
"kosmos_rsk::nginx_mainnet",
"kosmos_website",
"kosmos_website::default",
"kosmos-akkounts::nginx",
"kosmos-akkounts::nginx_api",
"kosmos-bitcoin::nginx_lndhub",
"kosmos_encfs",
"kosmos_encfs::default",
"kosmos-ejabberd::firewall",
@@ -69,6 +71,7 @@
"hostname::default",
"openresty::apt_package",
"openresty::ohai_plugin",
"openresty::commons_cleanup",
"openresty::commons_user",
"openresty::commons_dir",
"openresty::commons_script",

View File

@@ -25,8 +25,6 @@ default_run_list = %w(
kosmos_garage::firewall_rpc
kosmos_garage::nginx_web
kosmos-akkounts::nginx_api
kosmos-bitcoin::nginx_lndhub
kosmos-ejabberd::nginx
kosmos-hubot::nginx_botka_irc-libera-chat
kosmos-hubot::nginx_hal8000_xmpp
@@ -38,13 +36,15 @@ default_run_list = %w(
production_run_list = %w(
role[openresty]
kosmos_assets::nginx_site
kosmos-akkounts::nginx
kosmos_discourse::nginx
kosmos_drone::nginx
kosmos_gitea::nginx
kosmos_rsk::nginx_testnet
kosmos_rsk::nginx_mainnet
kosmos_website::default
kosmos-akkounts::nginx
kosmos-akkounts::nginx_api
kosmos-bitcoin::nginx_lndhub
)
env_run_lists(

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

View File

@@ -14,6 +14,7 @@ depends 'git'
depends 'golang'
depends 'kosmos-nginx'
depends 'kosmos-nodejs'
depends 'kosmos_openresty'
depends 'kosmos_postgresql'
depends 'postgresql'
depends 'redisio'

View File

@@ -3,27 +3,20 @@
# Recipe:: nginx_lndhub
#
include_recipe "kosmos-base::letsencrypt"
include_recipe "kosmos-nginx"
domain = node['lndhub-go']['domain']
nginx_certbot_site domain
upstream_host = search(:node, "role:lndhub").first["knife_zero"]["host"]
template "#{node['nginx']['dir']}/sites-available/#{domain}" do
source 'nginx_conf_lndhub.erb'
owner node["nginx"]["user"]
mode 0640
variables port: node['lndhub-go']['port'],
server_name: domain,
tls_cert_for domain do
auth "gandi_dns"
action :create
end
openresty_site domain do
template 'nginx_conf_lndhub.erb'
variables server_name: domain,
port: node['lndhub-go']['port'],
ssl_cert: "/etc/letsencrypt/live/#{domain}/fullchain.pem",
ssl_key: "/etc/letsencrypt/live/#{domain}/privkey.pem",
upstream_host: upstream_host
notifies :reload, 'service[nginx]', :delayed
end
nginx_site domain do
action :enable
end

View File

@@ -6,7 +6,7 @@ upstream _lndhub {
}
server {
listen 443 ssl http2;
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl http2;
listen [::]:443 ssl http2;
server_name <%= @server_name %>;