Migrate Drone CI proxy to openresty

This commit is contained in:
Râu Cao
2023-07-26 14:07:48 +02:00
parent 543b482adb
commit 53abc2ec9a
4 changed files with 9 additions and 15 deletions

View File

@@ -8,5 +8,5 @@ version '0.1.0'
chef_version '>= 14.0'
depends "firewall"
depends "kosmos-nginx"
depends "kosmos_gitea"
depends "kosmos_openresty"

View File

@@ -12,21 +12,16 @@ end
# No Discourse host, stop here
return if upstream_ip_addresses.empty?
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.erb"
owner 'www-data'
mode 0640
openresty_site domain do
template "nginx_conf.erb"
variables server_name: domain,
upstream_ip_addresses: upstream_ip_addresses,
upstream_port: node["kosmos_drone"]["upstream_port"],
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

@@ -1,4 +1,3 @@
<% if File.exist?(@ssl_cert) && File.exist?(@ssl_key) -%>
# Generated by Chef
upstream _drone {
<% @upstream_ip_addresses.each do |upstream_ip_address| -%>
@@ -8,7 +7,7 @@ upstream _drone {
server {
server_name <%= @server_name %>;
listen 443 ssl http2;
listen <%= "#{node['openresty']['listen_ip']}:" if node['openresty']['listen_ip'] %>443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate <%= @ssl_cert %>;
@@ -33,4 +32,3 @@ server {
proxy_http_version 1.1;
}
}
<% end -%>