Migrate IPFS proxies to openresty

This commit is contained in:
Râu Cao 2023-07-26 16:12:33 +02:00
parent 1362da0add
commit 027d0ed570
Signed by: raucao
GPG Key ID: 15E65F399D084BA9
5 changed files with 14 additions and 19 deletions

View File

@ -48,6 +48,7 @@
"kosmos-akkounts::nginx", "kosmos-akkounts::nginx",
"kosmos-akkounts::nginx_api", "kosmos-akkounts::nginx_api",
"kosmos-bitcoin::nginx_lndhub", "kosmos-bitcoin::nginx_lndhub",
"kosmos-ipfs::nginx_public_gateway",
"kosmos-mastodon::nginx", "kosmos-mastodon::nginx",
"remotestorage_discourse::nginx", "remotestorage_discourse::nginx",
"kosmos_encfs", "kosmos_encfs",
@ -83,7 +84,8 @@
"git::default", "git::default",
"git::package", "git::package",
"kosmos-base::letsencrypt", "kosmos-base::letsencrypt",
"firewall::default" "firewall::default",
"fail2ban::default"
], ],
"platform": "ubuntu", "platform": "ubuntu",
"platform_version": "20.04", "platform_version": "20.04",

View File

@ -28,7 +28,6 @@ default_run_list = %w(
kosmos-hubot::nginx_botka_irc-libera-chat kosmos-hubot::nginx_botka_irc-libera-chat
kosmos-hubot::nginx_hal8000_xmpp kosmos-hubot::nginx_hal8000_xmpp
kosmos-ipfs::nginx_public_gateway
) )
production_run_list = %w( production_run_list = %w(
@ -43,6 +42,7 @@ production_run_list = %w(
kosmos-akkounts::nginx kosmos-akkounts::nginx
kosmos-akkounts::nginx_api kosmos-akkounts::nginx_api
kosmos-bitcoin::nginx_lndhub kosmos-bitcoin::nginx_lndhub
kosmos-ipfs::nginx_public_gateway
kosmos-mastodon::nginx kosmos-mastodon::nginx
remotestorage_discourse::nginx remotestorage_discourse::nginx
) )

View File

@ -9,6 +9,6 @@ version '0.3.0'
depends 'ipfs' depends 'ipfs'
depends 'fail2ban' depends 'fail2ban'
depends 'kosmos-base' depends 'kosmos-base'
depends 'kosmos-nginx'
depends 'kosmos-nodejs' depends 'kosmos-nodejs'
depends 'kosmos_openresty'
depends 'firewall' depends 'firewall'

View File

@ -3,7 +3,6 @@
# Recipe:: nginx_public_gateway # Recipe:: nginx_public_gateway
# #
include_recipe "kosmos-nginx"
include_recipe 'firewall' include_recipe 'firewall'
domain = node["kosmos-ipfs"]["nginx"]["domain"] domain = node["kosmos-ipfs"]["nginx"]["domain"]
@ -13,12 +12,13 @@ search(:node, "role:ipfs_gateway").each do |node|
ipfs_node_ip_addresses << node["knife_zero"]["host"] ipfs_node_ip_addresses << node["knife_zero"]["host"]
end end
nginx_certbot_site domain tls_cert_for domain do
auth "gandi_dns"
action :create
end
template "#{node['nginx']['dir']}/sites-available/#{domain}" do openresty_site domain do
source "nginx_conf_#{domain}.erb" template "nginx_conf_#{domain}.erb"
owner 'www-data'
mode 0640
variables server_name: domain, variables server_name: domain,
ssl_cert: "/etc/letsencrypt/live/#{domain}/fullchain.pem", ssl_cert: "/etc/letsencrypt/live/#{domain}/fullchain.pem",
ssl_key: "/etc/letsencrypt/live/#{domain}/privkey.pem", ssl_key: "/etc/letsencrypt/live/#{domain}/privkey.pem",
@ -26,12 +26,6 @@ template "#{node['nginx']['dir']}/sites-available/#{domain}" do
ipfs_gateway_port: node['kosmos-ipfs']['gateway_port'], ipfs_gateway_port: node['kosmos-ipfs']['gateway_port'],
ipfs_external_api_port: node['kosmos-ipfs']['nginx']['external_api_port'], ipfs_external_api_port: node['kosmos-ipfs']['nginx']['external_api_port'],
upstream_hosts: ipfs_node_ip_addresses upstream_hosts: ipfs_node_ip_addresses
notifies :reload, 'service[nginx]', :delayed
end
nginx_site domain do
action :enable
end end
firewall_rule 'ipfs_api' do firewall_rule 'ipfs_api' do

View File

@ -10,10 +10,9 @@ upstream _ipfs_api {
} }
server { server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name <%= @server_name %>; server_name <%= @server_name %>;
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl http2;
listen [::]:443 ssl http2;
access_log /var/log/nginx/<%= @server_name %>.access.log; access_log /var/log/nginx/<%= @server_name %>.access.log;
error_log /var/log/nginx/<%= @server_name %>.error.log; error_log /var/log/nginx/<%= @server_name %>.error.log;
@ -28,7 +27,7 @@ server {
server { server {
<% if File.exist?(@ssl_cert) && File.exist?(@ssl_key) -%> <% if File.exist?(@ssl_cert) && File.exist?(@ssl_key) -%>
listen <%= @ipfs_external_api_port %> ssl http2; listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %><%= @ipfs_external_api_port %> ssl http2;
<% else -%> <% else -%>
listen <%= @ipfs_external_api_port %>; listen <%= @ipfs_external_api_port %>;
<% end -%> <% end -%>