From 7b6168306ae440a781970d4b19478381548e73df Mon Sep 17 00:00:00 2001 From: Mikhail Zholobov Date: Sun, 7 Feb 2016 20:04:54 +0200 Subject: [PATCH] Redirect HTTP to HTTPS We use Apache web server in the front of Tomcat. Since we configure SSL in Apache by default, we can also add a rewrite rule to the virtual host configuration in order to force HTTPS. And we don't need to configure proxy for HTTP-based virtual host anymore. --- templates/default/web_app.conf.erb | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/templates/default/web_app.conf.erb b/templates/default/web_app.conf.erb index cc28e81..d410d15 100644 --- a/templates/default/web_app.conf.erb +++ b/templates/default/web_app.conf.erb @@ -18,16 +18,9 @@ ErrorLog <%= node['stash']['apache2']['error_log'].empty? ? node['apache']['log_dir']+"/stash-error.log" : node['stash']['apache2']['error_log'] %> LogLevel warn - - <% if node['apache'] && node['apache']['version'] == '2.4' %> - Require all granted - <% else %> - Order Deny,Allow - Allow from all - <% end %> - - ProxyPass / http://localhost:<%= node['stash']['tomcat']['port'] %>/ connectiontimeout=5 timeout=300 - ProxyPassReverse / http://localhost:<%= node['stash']['tomcat']['port'] %>/ + RewriteEngine On + RewriteCond %{HTTPS} off + RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} >