summaryrefslogtreecommitdiff
path: root/puppet/modules/site_apache/templates/vhosts.d/api.conf.erb
blob: bfa5d04dd5f155bf838540f5294dee2f1d40b1e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<VirtualHost *:80>
  ServerName <%= @api_domain %>
  RewriteEngine On
  RewriteRule ^.*$ https://<%= @api_domain -%>:<%= @api_port -%>%{REQUEST_URI} [R=permanent,L]
  CustomLog ${APACHE_LOG_DIR}/other_vhosts_access.log common
</VirtualHost>

Listen 0.0.0.0:<%= @api_port %>

<VirtualHost *:<%= @api_port -%>>
  ServerName <%= @api_domain %>
  CustomLog ${APACHE_LOG_DIR}/other_vhosts_access.log common

  SSLCACertificatePath /etc/ssl/certs
  SSLCertificateKeyFile <%= scope.lookupvar('x509::variables::keys') %>/<%= scope.lookupvar('site_config::params::cert_name') %>.key
  SSLCertificateFile <%= scope.lookupvar('x509::variables::certs') %>/<%= scope.lookupvar('site_config::params::cert_name') %>.crt

  Include include.d/ssl_common.inc

  <IfModule mod_headers.c>
<% if @webapp['secure'] -%>
    Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
<% end -%>
    Header always unset X-Powered-By
    Header always unset X-Runtime
  </IfModule>

  DocumentRoot /srv/leap/webapp/public
  <% if scope.function_guess_apache_version([]) == '2.4' %>
  <Directory /srv/leap/webapp/public>
    AllowOverride None
    Require all granted
  </Directory>
  <% end %>

  # Check for maintenance file and redirect all requests
  RewriteEngine On
  RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
  RewriteCond %{SCRIPT_FILENAME} !maintenance.html
  RewriteCond %{REQUEST_URI} !/images/maintenance.jpg
  RewriteRule ^.*$ %{DOCUMENT_ROOT}/system/maintenance.html [L]

  # http://www.modrails.com/documentation/Users%20guide%20Apache.html#_passengerallowencodedslashes_lt_on_off_gt
  AllowEncodedSlashes on
  PassengerAllowEncodedSlashes on
  PassengerFriendlyErrorPages off
  SetEnv TMPDIR /var/tmp
</VirtualHost>