cloudamatic/mu

View on GitHub
cookbooks/mu-master/templates/default/web_app.conf.erb

Summary

Maintainability
Test Coverage
<VirtualHost *:<%= @server_port || (node['apache'] and node['apache']['listen'].first) %>>
  ServerName <%= @server_name %>
  ServerAlias <% @server_aliases.each do |a| %><%= a %> <% end %>
  DocumentRoot <%= @docroot %>
  FileETag -INode
  RewriteEngine On
  RewriteRule ^/(nagios|jenkins|scratchpad)$ https://%{HTTP_HOST}/$1/ [R=301,NC,L]

<% if @server_port.to_s.match(/443$/) %>
  SSLEngine On
  SSLCertificateFile <%= $MU_CFG['ssl']['cert'] %>
  SSLCertificateKeyFile <%= $MU_CFG['ssl']['key'] %>
<% if $MU_CFG['ssl'].has_key?("chain") and !$MU_CFG['ssl']['chain'].empty? %>
  SSLCertificateChainFile <%= $MU_CFG['ssl']['chain'] %>
<% end %>
  SSLProxyEngine on
  <Proxy *>
    Require all granted
  </Proxy>

  ProxyPreserveHost on
  AllowEncodedSlashes off
  
  # Scratchpad, the Mu secret-sharer
  ProxyPass /scratchpad https://localhost:<%= MU.mommaCatPort.to_s %>/scratchpad
  ProxyPassReverse /scratchpad https://localhost:<%= MU.mommaCatPort.to_s %>/scratchpad

  # Nagios web UI
  ProxyPass /nagios/ https://localhost:8443/nagios/
  ProxyPassReverse /nagios/ https://localhost:8443/nagios/

  ProxyPass /cloudamatic.png !
  ProxyPass /docs/ !
  ProxyPass /index.html !

  # Everything else should go to the Chef API endpoint
  ProxyPass / https://localhost:7443/
  ProxyPassReverse / https://localhost:7443/

  RequestHeader set X-Forwarded-Proto "https"

<% else %>
  RewriteRule ^/(nagios|jenkins|scratchpad)/(.*) https://%{HTTP_HOST}/$1/$2 [R=301,NC,L]
<% end %>

  RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
  RewriteRule .* - [F]

  <DirectoryMatch "<%= @docroot %>\/.*">
    Options <%= [@directory_options || "FollowSymLinks" ].flatten.join " " %>
    AllowOverride <%= [@allow_override || "None" ].flatten.join " " %>
    Require all granted
  </DirectoryMatch>

  <Directory />
    Options FollowSymLinks
    AllowOverride None
  </Directory>

  <Location /server-status>
    SetHandler server-status
    Require host 127.0.0.1
  </Location>


  <% if @directory_index -%>
  DirectoryIndex <%= [@directory_index].flatten.join " " %>
  <% end -%>

</VirtualHost>