%
@path = "/etc/apache2/sites-available/#{rubber_env.app_name}-tools"
@post = "a2enmod rewrite && a2enmod ssl && a2enmod proxy_http && a2enmod proxy_html && a2ensite #{rubber_env.app_name}-tools"
%>
Listen <%= rubber_env.web_tools_port %>
>
ServerName <%= rubber_env.full_host %>
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^/(.*)$ https://%{SERVER_NAME}:<%= rubber_env.web_tools_ssl_port %>/$1 [L,R]
RewriteLog "/var/log/apache2/rewrite.log"
Listen <%= rubber_env.web_tools_ssl_port %>
>
ServerName <%= rubber_env.full_host %>
DocumentRoot /var/www
SSLEngine on
SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
# SSLCertificateFile <%= RUBBER_ROOT %>/config/<%= rubber_env.domain %>.crt
# SSLCertificateKeyFile <%= RUBBER_ROOT %>/config/<%= rubber_env.domain %>.key
# SSLCertificateChainFile /etc/ssl/certs/gd_intermediate_bundle.crt
AuthType Basic
AuthName "Rubber Admin Tools"
AuthUserFile <%= RUBBER_ROOT %>/config/<%= rubber_env.app_name %>.auth
Require valid-user
Allow from all
SetOutputFilter proxy-html
<% rubber_instances.for_role('haproxy').each do |ic| %>
ProxyPass /haproxy_<%= ic.name %>/ http://<%= ic.full_name %>:<%= rubber_env.haproxy_admin_port %>/haproxy/
/>
ProxyPassReverse /
ProxyHTMLURLMap http://<%= ic.full_name %>:<%= rubber_env.haproxy_admin_port %>/ /haproxy_<%= ic.name %>/
ProxyHTMLURLMap /haproxy/ /haproxy_<%= ic.name %>/
ProxyHTMLURLMap /haproxy /haproxy_<%= ic.name %>/
<% end %>
<% if cruise_host = rubber_instances.for_role('cruise').first %>
ProxyPass /cruise/ http://<%= cruise_host.full_name %>:<%= rubber_env.cruise_port %>/
ProxyPassReverse /
ProxyHTMLURLMap http://<%= cruise_host.full_name %>:<%= rubber_env.cruise_port %>/ /cruise/
ProxyHTMLURLMap / /cruise/
<% end %>
<% rubber_instances.each do |ic| %>
ProxyPass /monit_<%= ic.name %>/ http://<%= ic.full_name %>:<%= rubber_env.monit_admin_port %>/
/>
ProxyPassReverse /
ProxyHTMLURLMap http://<%= ic.full_name %>:<%= rubber_env.monit_admin_port %>/ /monit_<%= ic.name %>/
ProxyHTMLURLMap / /monit_<%= ic.name %>/
<% end %>
<% if resque_host = rubber_instances.for_role('resque_web').first %>
ProxyPass /resque/ http://<%= resque_host.full_name %>:<%= rubber_env.resque_web_port %>/
# special case, sinatra is using X-Forwarded-Host header to set redirects (Location header) to our external address, so we have to rewrite that to the right path
ProxyPassReverse /resque/ http://<%= rubber_env.full_host %>:<%= rubber_env.web_tools_ssl_port %>/
ProxyPassReverse /
ProxyHTMLURLMap http://<%= resque_host.full_name %>:<%= rubber_env.resque_web_port %>/ /resque/
ProxyHTMLURLMap / /resque/
<% end %>