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
5 changed files with 14 additions and 19 deletions

View File

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

View File

@@ -3,7 +3,6 @@
# Recipe:: nginx_public_gateway
#
include_recipe "kosmos-nginx"
include_recipe 'firewall'
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"]
end
nginx_certbot_site domain
tls_cert_for domain do
auth "gandi_dns"
action :create
end
template "#{node['nginx']['dir']}/sites-available/#{domain}" do
source "nginx_conf_#{domain}.erb"
owner 'www-data'
mode 0640
openresty_site domain do
template "nginx_conf_#{domain}.erb"
variables server_name: domain,
ssl_cert: "/etc/letsencrypt/live/#{domain}/fullchain.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_external_api_port: node['kosmos-ipfs']['nginx']['external_api_port'],
upstream_hosts: ipfs_node_ip_addresses
notifies :reload, 'service[nginx]', :delayed
end
nginx_site domain do
action :enable
end
firewall_rule 'ipfs_api' do

View File

@@ -10,10 +10,9 @@ upstream _ipfs_api {
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
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;
error_log /var/log/nginx/<%= @server_name %>.error.log;
@@ -28,7 +27,7 @@ server {
server {
<% 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 -%>
listen <%= @ipfs_external_api_port %>;
<% end -%>