Don't fail on first run, when Tor hostname missing

This commit is contained in:
Basti 2021-01-13 09:49:03 +01:00 committed by Greg Karékinian
parent ad64bfc0be
commit 8a870f6fd6
2 changed files with 5 additions and 1 deletions

View File

@ -24,6 +24,8 @@ template "#{node['nginx']['dir']}/snippets/mastodon.conf" do
notifies :reload, 'service[nginx]', :delayed
end
onion_address = File.read("/var/lib/tor/mastodon/hostname").strip rescue nil
template "#{node['nginx']['dir']}/sites-available/#{server_name}" do
source 'nginx_conf_mastodon.erb'
owner 'www-data'
@ -32,7 +34,7 @@ template "#{node['nginx']['dir']}/sites-available/#{server_name}" do
ssl_cert: "/etc/letsencrypt/live/#{server_name}/fullchain.pem",
ssl_key: "/etc/letsencrypt/live/#{server_name}/privkey.pem",
shared_config_path: "#{node['nginx']['dir']}/snippets/mastodon.conf",
onion_address: File.read("/var/lib/tor/mastodon/hostname").strip
onion_address: onion_address
notifies :reload, 'service[nginx]', :delayed
end

View File

@ -1,8 +1,10 @@
<% if @onion_address %>
server {
listen 80;
server_name mastodon.<%= @onion_address %>;
include <%= @shared_config_path %>;
}
<% end %>
map $http_upgrade $connection_upgrade {
default upgrade;