From b21a3e9126a1734b2cea975e57b5c9e8206f12fa Mon Sep 17 00:00:00 2001 From: elijah Date: Mon, 27 Jun 2016 15:49:30 -0700 Subject: Fix the permissions on the DOMAIN/provider.json file for static sites. --- puppet/modules/site_static/templates/apache.conf.erb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'puppet/modules/site_static/templates/apache.conf.erb') diff --git a/puppet/modules/site_static/templates/apache.conf.erb b/puppet/modules/site_static/templates/apache.conf.erb index 6b969d1c..b3e5fc09 100644 --- a/puppet/modules/site_static/templates/apache.conf.erb +++ b/puppet/modules/site_static/templates/apache.conf.erb @@ -23,6 +23,10 @@ bootstrap_client = scope.lookupvar('site_static::bootstrap_client') -%> + + Require all granted + + ServerName <%= @domain %> ServerAlias www.<%= @domain %> @@ -46,7 +50,7 @@ #RewriteLogLevel 3 Include include.d/ssl_common.inc - + <%- if @tls_only -%> Header always set Strict-Transport-Security: "max-age=15768000;includeSubdomains" <%- end -%> @@ -63,7 +67,7 @@ AccessFileName .htaccess <%- if ([@aliases]+[@domain]).flatten.include?(bootstrap_domain) -%> - Alias /provider.json /srv/leap/provider.json + Alias /provider.json /srv/static/public/provider.json Header set X-Minimum-Client-Version <%= bootstrap_client['min'] %> -- cgit v1.2.3 From 29d6b7dbbc3b9d8b11f0b215cad894fcfca9989c Mon Sep 17 00:00:00 2001 From: Micah Date: Thu, 23 Jun 2016 12:08:54 -0400 Subject: Make static tor hidden services work (#8212). When tor hidden services were enabled for static sites, only a very basic configuration was setup and it didn't take into account the different location configurations that can be configured for a static site. This commit resolves that by making a site_static::hidden_service class similar to the site_webapp::hidden_service class, and fixes up the apache vhost template to properly create the location blocks for the hidden service vhost. Change-Id: Ice3586f4173bd2d1bd3defca29d21c7403d5a03a --- .../modules/site_static/templates/apache.conf.erb | 45 +++++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'puppet/modules/site_static/templates/apache.conf.erb') diff --git a/puppet/modules/site_static/templates/apache.conf.erb b/puppet/modules/site_static/templates/apache.conf.erb index b3e5fc09..2013e5ee 100644 --- a/puppet/modules/site_static/templates/apache.conf.erb +++ b/puppet/modules/site_static/templates/apache.conf.erb @@ -27,12 +27,52 @@ Require all granted +<%- if @tor -%> + + ServerName <%= @tor_domain %> + ServerAlias www.<%= @tor_domain %> + + + Header set X-Frame-Options "deny" + Header always unset X-Powered-By + Header always unset X-Runtime + + + DocumentRoot "/<%= @document_root %>/" + AccessFileName .htaccess + +<%- if ([@aliases]+[@domain]).flatten.include?(bootstrap_domain) -%> + Alias /provider.json /srv/leap/provider.json + + Header set X-Minimum-Client-Version <%= bootstrap_client['min'] %> + +<%- end -%> + +<%- if @apache_config -%> +<%= @apache_config.gsub(':percent:','%') %> +<%- end -%> + +<%- @locations && @locations.each do |name, location| -%> +<%- location_path = location['path'].gsub(%r{^/|/$}, '') -%> +<%- directory = location_directory(name, location) -%> +<%- local_vars = {'location_path'=>location_path, 'directory'=>directory, 'location'=>location, 'name'=>name} -%> +<%- template_path = File.join(File.dirname(__FILE__), location['format']) + '.erb' -%> +<%- break unless File.exists?(template_path) -%> + ## + ## <%= name %> (<%= location['format'] %>) + ## +<%= scope.function_templatewlv([template_path, local_vars]) %> +<%- end -%> +<%- end -%> + + ServerName <%= @domain %> ServerAlias www.<%= @domain %> <%- @aliases && @aliases.each do |domain_alias| -%> ServerAlias <%= domain_alias %> <%- end -%> + <%- if @tls_only -%> RewriteEngine On RewriteRule ^.*$ https://<%= @domain -%>%{REQUEST_URI} [R=permanent,L] @@ -50,13 +90,15 @@ #RewriteLogLevel 3 Include include.d/ssl_common.inc - + + <%- if @tls_only -%> Header always set Strict-Transport-Security: "max-age=15768000;includeSubdomains" <%- end -%> Header set X-Frame-Options "deny" Header always unset X-Powered-By Header always unset X-Runtime + SSLCertificateKeyFile /etc/x509/keys/<%= @domain %>.key SSLCertificateFile /etc/x509/certs/<%= @domain %>.crt @@ -88,5 +130,4 @@ ## <%= scope.function_templatewlv([template_path, local_vars]) %> <%- end -%> - -- cgit v1.2.3 From cfb91a199c8c205b99c4424df77b0b6ed20e4288 Mon Sep 17 00:00:00 2001 From: elijah Date: Thu, 30 Jun 2016 12:15:39 -0700 Subject: fix static site apache config --- .../modules/site_static/templates/apache.conf.erb | 122 ++++++++++++--------- 1 file changed, 72 insertions(+), 50 deletions(-) (limited to 'puppet/modules/site_static/templates/apache.conf.erb') diff --git a/puppet/modules/site_static/templates/apache.conf.erb b/puppet/modules/site_static/templates/apache.conf.erb index 2013e5ee..af9a520d 100644 --- a/puppet/modules/site_static/templates/apache.conf.erb +++ b/puppet/modules/site_static/templates/apache.conf.erb @@ -11,6 +11,9 @@ end end + # + # document root + # @document_root = begin root = '/var/www' @locations && @locations.each do |name, location| @@ -19,8 +22,52 @@ root.gsub(%r{^/|/$}, '') end + # + # provider.json + # + # if the domain is a bootstrap domain, we need to expose + # a /provider.json file. + # bootstrap_domain = scope.lookupvar('site_static::bootstrap_domain') bootstrap_client = scope.lookupvar('site_static::bootstrap_client') + if ([@aliases]+[@domain]).flatten.include?(bootstrap_domain) + provider_json = \ +%( + Alias /provider.json /srv/static/public/provider.json + + Header set X-Minimum-Client-Version #{bootstrap_client['min']} + +) + else + provider_json = "" + end + + # + # locations + # + locations = "" + @locations && @locations.each do |name, location| + location_path = location['path'].gsub(%r{^/|/$}, '') + directory = location_directory(name, location) + local_vars = {'location_path'=>location_path, 'directory'=>directory, 'location'=>location, 'name'=>name} + template_path = File.join(File.dirname(__FILE__), location['format']) + '.erb' + break unless File.exists?(template_path) + locations += \ +%( + # + # #{name} (#{location['format']}) + # +#{scope.function_templatewlv([template_path, local_vars])} +) + end + + # + # allow custom apache config + # + custom_apache_config = if @apache_config + @apache_config.gsub(':percent:','%') + end + -%> @@ -28,6 +75,9 @@ <%- if @tor -%> +## +## Tor +## ServerName <%= @tor_domain %> ServerAlias www.<%= @tor_domain %> @@ -41,31 +91,15 @@ DocumentRoot "/<%= @document_root %>/" AccessFileName .htaccess -<%- if ([@aliases]+[@domain]).flatten.include?(bootstrap_domain) -%> - Alias /provider.json /srv/leap/provider.json - - Header set X-Minimum-Client-Version <%= bootstrap_client['min'] %> - -<%- end -%> - -<%- if @apache_config -%> -<%= @apache_config.gsub(':percent:','%') %> -<%- end -%> - -<%- @locations && @locations.each do |name, location| -%> -<%- location_path = location['path'].gsub(%r{^/|/$}, '') -%> -<%- directory = location_directory(name, location) -%> -<%- local_vars = {'location_path'=>location_path, 'directory'=>directory, 'location'=>location, 'name'=>name} -%> -<%- template_path = File.join(File.dirname(__FILE__), location['format']) + '.erb' -%> -<%- break unless File.exists?(template_path) -%> - ## - ## <%= name %> (<%= location['format'] %>) - ## -<%= scope.function_templatewlv([template_path, local_vars]) %> -<%- end -%> -<%- end -%> +<%= provider_json %> +<%= custom_apache_config %> +<%= locations %> +<%- end -%> +## +## HTTP +## ServerName <%= @domain %> ServerAlias www.<%= @domain %> @@ -76,9 +110,16 @@ <%- if @tls_only -%> RewriteEngine On RewriteRule ^.*$ https://<%= @domain -%>%{REQUEST_URI} [R=permanent,L] +<%- else -%> +<%= provider_json %> +<%= custom_apache_config %> +<%= locations %> <%- end -%> +## +## HTTPS +## ServerName <%= @domain %> ServerAlias www.<%= @domain %> @@ -90,14 +131,14 @@ #RewriteLogLevel 3 Include include.d/ssl_common.inc - + <%- if @tls_only -%> - Header always set Strict-Transport-Security: "max-age=15768000;includeSubdomains" + Header always set Strict-Transport-Security: "max-age=15768000;includeSubdomains" <%- end -%> - Header set X-Frame-Options "deny" - Header always unset X-Powered-By - Header always unset X-Runtime + Header set X-Frame-Options "deny" + Header always unset X-Powered-By + Header always unset X-Runtime SSLCertificateKeyFile /etc/x509/keys/<%= @domain %>.key @@ -108,26 +149,7 @@ DocumentRoot "/<%= @document_root %>/" AccessFileName .htaccess -<%- if ([@aliases]+[@domain]).flatten.include?(bootstrap_domain) -%> - Alias /provider.json /srv/static/public/provider.json - - Header set X-Minimum-Client-Version <%= bootstrap_client['min'] %> - -<%- end -%> - -<%- if @apache_config -%> -<%= @apache_config.gsub(':percent:','%') %> -<%- end -%> - -<%- @locations && @locations.each do |name, location| -%> -<%- location_path = location['path'].gsub(%r{^/|/$}, '') -%> -<%- directory = location_directory(name, location) -%> -<%- local_vars = {'location_path'=>location_path, 'directory'=>directory, 'location'=>location, 'name'=>name} -%> -<%- template_path = File.join(File.dirname(__FILE__), location['format']) + '.erb' -%> -<%- break unless File.exists?(template_path) -%> - ## - ## <%= name %> (<%= location['format'] %>) - ## -<%= scope.function_templatewlv([template_path, local_vars]) %> -<%- end -%> +<%= provider_json %> +<%= custom_apache_config %> +<%= locations %> -- cgit v1.2.3 From a063280eab5e8749c74381aabbe641c30887e9f6 Mon Sep 17 00:00:00 2001 From: elijah Date: Fri, 2 Sep 2016 12:35:09 -0700 Subject: [bugfix] static sites: only enable hidden service by default if one domain is configured The problem is that we have a single onion address per server, so if more than one domain is configured we need to make sure they don't both try to use the same onion address. --- puppet/modules/site_static/templates/apache.conf.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'puppet/modules/site_static/templates/apache.conf.erb') diff --git a/puppet/modules/site_static/templates/apache.conf.erb b/puppet/modules/site_static/templates/apache.conf.erb index af9a520d..dd04ca43 100644 --- a/puppet/modules/site_static/templates/apache.conf.erb +++ b/puppet/modules/site_static/templates/apache.conf.erb @@ -74,7 +74,7 @@ Require all granted -<%- if @tor -%> +<%- if @tor && (@always_use_hidden_service || @use_hidden_service) -%> ## ## Tor ## -- cgit v1.2.3