Add HTTP redirects for kosmos.chat and kosmos.cash

This commit is contained in:
Râu Cao 2024-08-04 16:49:20 +02:00
parent 5e727ec279
commit 1c8ee14bb3
Signed by: raucao
GPG Key ID: 37036C356E56CC51
5 changed files with 58 additions and 0 deletions

View File

@ -57,6 +57,7 @@
"kosmos_strfry::nginx",
"kosmos_website",
"kosmos_website::default",
"kosmos_website::redirects",
"kosmos-akkounts::nginx",
"kosmos-akkounts::nginx_api",
"kosmos-bitcoin::nginx_lndhub",

View File

@ -51,6 +51,7 @@
"kosmos_strfry::nginx",
"kosmos_website",
"kosmos_website::default",
"kosmos_website::redirects",
"kosmos-akkounts::nginx",
"kosmos-akkounts::nginx_api",
"kosmos-bitcoin::nginx_lndhub",

View File

@ -30,6 +30,7 @@ production_run_list = %w(
kosmos_rsk::nginx_mainnet
kosmos_strfry::nginx
kosmos_website::default
kosmos_website::redirects
kosmos-akkounts::nginx
kosmos-akkounts::nginx_api
kosmos-bitcoin::nginx_lndhub

View File

@ -0,0 +1,35 @@
#
# Cookbook:: kosmos_website
# Recipe:: redirects
#
redirects = [
{
domain: "kosmos.chat",
target: "https://kosmos.org",
http_status: 307
},
{
domain: "kosmos.cash",
acme_domain: "letsencrypt.kosmos.org",
target: "https://kosmos.org",
http_status: 307
}
]
redirects.each do |redirect|
tls_cert_for redirect[:domain] do
auth "gandi_dns"
acme_domain redirect[:acme_domain] unless redirect[:acme_domain].nil?
action :create
end
openresty_site redirect[:domain] do
template "nginx_conf_redirect.erb"
variables domain: redirect[:domain],
target: redirect[:target],
http_status: redirect[:http_status],
ssl_cert: "/etc/letsencrypt/live/#{redirect[:domain]}/fullchain.pem",
ssl_key: "/etc/letsencrypt/live/#{redirect[:domain]}/privkey.pem"
end
end

View File

@ -0,0 +1,20 @@
# Generated by Chef
server {
server_name <%= @domain %>;
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl http2;
listen [::]:443 ssl http2;
access_log <%= node[:openresty][:log_dir] %>/<%= @domain %>.access.log;
error_log <%= node[:openresty][:log_dir] %>/<%= @domain %>.error.log warn;
gzip_static on;
gzip_comp_level 5;
ssl_certificate <%= @ssl_cert %>;
ssl_certificate_key <%= @ssl_key %>;
location / {
return <%= @http_status || 301 %> <%= @target %>;
}
}