Migrate RS Discourse proxy to openresty
This commit is contained in:
parent
15b2ea284a
commit
1362da0add
@ -49,6 +49,7 @@
|
||||
"kosmos-akkounts::nginx_api",
|
||||
"kosmos-bitcoin::nginx_lndhub",
|
||||
"kosmos-mastodon::nginx",
|
||||
"remotestorage_discourse::nginx",
|
||||
"kosmos_encfs",
|
||||
"kosmos_encfs::default",
|
||||
"kosmos-ejabberd::firewall",
|
||||
|
@ -29,7 +29,6 @@ default_run_list = %w(
|
||||
kosmos-hubot::nginx_botka_irc-libera-chat
|
||||
kosmos-hubot::nginx_hal8000_xmpp
|
||||
kosmos-ipfs::nginx_public_gateway
|
||||
remotestorage_discourse::nginx
|
||||
)
|
||||
|
||||
production_run_list = %w(
|
||||
@ -45,6 +44,7 @@ production_run_list = %w(
|
||||
kosmos-akkounts::nginx_api
|
||||
kosmos-bitcoin::nginx_lndhub
|
||||
kosmos-mastodon::nginx
|
||||
remotestorage_discourse::nginx
|
||||
)
|
||||
|
||||
env_run_lists(
|
||||
|
@ -1,2 +0,0 @@
|
||||
node.override['discourse']['domain'] = "community.remotestorage.io"
|
||||
node.override['discourse']['role'] = "remotestorage_discourse"
|
@ -2,9 +2,11 @@ name 'remotestorage_discourse'
|
||||
maintainer 'Kosmos Developers'
|
||||
maintainer_email 'mail@kosmos.org'
|
||||
license 'MIT'
|
||||
description 'Installs/Configures discourse'
|
||||
long_description 'Installs/Configures discourse'
|
||||
version '0.1.0'
|
||||
description 'Installs/configures Discourse'
|
||||
long_description 'Installs/configures Discourse'
|
||||
version '0.2.0'
|
||||
chef_version '>= 14.0'
|
||||
|
||||
depends 'discourse'
|
||||
depends 'firewall'
|
||||
depends 'kosmos_openresty'
|
||||
|
@ -3,4 +3,30 @@
|
||||
# Recipe:: nginx
|
||||
#
|
||||
|
||||
include_recipe "discourse::nginx"
|
||||
domain = "community.remotestorage.io"
|
||||
discourse_role = "remotestorage_discourse"
|
||||
|
||||
upstream_ip_addresses = []
|
||||
search(:node, "role:#{discourse_role}").each do |n|
|
||||
upstream_ip_addresses << n["knife_zero"]["host"]
|
||||
end
|
||||
# No Discourse host, stop here
|
||||
if upstream_ip_addresses.empty?
|
||||
Chef::Log.warn("No server with '#{discourse_role}' role. Stopping here.")
|
||||
return
|
||||
end
|
||||
|
||||
tls_cert_for domain do
|
||||
auth "gandi_dns"
|
||||
action :create
|
||||
end
|
||||
|
||||
openresty_site domain do
|
||||
template "nginx_conf.erb"
|
||||
variables server_name: domain,
|
||||
ssl_cert: "/etc/letsencrypt/live/#{domain}/fullchain.pem",
|
||||
ssl_key: "/etc/letsencrypt/live/#{domain}/privkey.pem",
|
||||
upstream_port: node['discourse']['port'],
|
||||
upstream_name: discourse_role,
|
||||
upstream_ip_addresses: upstream_ip_addresses
|
||||
end
|
||||
|
@ -1,14 +1,13 @@
|
||||
# Generated by Chef
|
||||
upstream _discourse {
|
||||
upstream _rs_discourse {
|
||||
<% @upstream_ip_addresses.each do |upstream_ip_address| -%>
|
||||
server <%= upstream_ip_address %>:<%= @upstream_port %>;
|
||||
<% end -%>
|
||||
}
|
||||
|
||||
<% if File.exist?(@ssl_cert) && File.exist?(@ssl_key) -%>
|
||||
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 %>;
|
||||
@ -28,8 +27,7 @@ server {
|
||||
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
proxy_pass http://_discourse;
|
||||
proxy_pass http://_rs_discourse;
|
||||
proxy_http_version 1.1;
|
||||
}
|
||||
}
|
||||
<% end -%>
|
||||
|
Loading…
x
Reference in New Issue
Block a user