default-virtualhost.conf.in 3.17 KB
Newer Older
1
{% set TRUE_VALUES = ['y', 'yes', '1', 'true'] -%}
2 3
 
<VirtualHost *:{{ https_port }}>
4 5
  ServerName {{ slave_parameter.get('domain') }}
  ServerAlias {{ slave_parameter.get('domain') }}
6

7 8
  SSLEngine on
  SSLProxyEngine on
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
  SSLProtocol -ALL +SSLv3 +TLSv1
  SSLHonorCipherOrder On
  SSLCipherSuite RC4-SHA:HIGH:!ADH

{% set ssl_configuration_list = [('SSLCertificateFile', 'path_to_ssl_crt'),
       			      	 ('SSLCertificateKeyFile', 'path_to_ssl_key'),
                                 ('SSLCACertificateFile', 'path_to_ssl_ca_crt'),
                                 ('SSLCertificateChainFile', 'path_to_ssl_ca_crt')] -%}

{% for key, value in ssl_configuration_list -%}
{%   if value in slave_parameter -%}
{{ '  %s' % key }} {{ slave_parameter.get(value) }}
{% endif -%}
{% endfor -%}

24 25 26

  # One Slave two logs
  ErrorLog "{{ error_log }}"
27
  LogLevel info
28 29 30
  LogFormat "%h %l %{REMOTE_USER}i %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %D" combined
  CustomLog "{{ access_log }}" combined

31 32 33 34 35 36 37
  # Rewrite part
  ProxyVia On
  ProxyPreserveHost On
  ProxyTimeout 600
  RewriteEngine On

{% if slave_parameter.get('type', '') ==  'zope' -%}
38 39
  # First, we check if we have a zope backend server
  # If so, let's use Virtual Host Daemon rewrite
40 41
  # We suppose that Apache listens to 443 (even indirectly thanks to things like iptables)
  RewriteRule ^/(.*)$ {{ slave_parameter.get('url', '') }}/VirtualHostBase/https/{{ slave_parameter.get('domain', '') }}:443/{{ slave_parameter.get('path', '') }}/VirtualHostRoot/$1 [L,P]
42 43 44 45 46
{% else -%}
  RewriteRule ^/(.*)$ {{ slave_parameter.get('url', '') }}/$1 [L,P]
{% endif -%}
</VirtualHost>

47
<VirtualHost *:{{ http_port }}>
48 49
  ServerName {{ slave_parameter.get('domain') }}
  ServerAlias {{ slave_parameter.get('domain') }}
50
  SSLEngine on
51 52 53 54 55 56 57 58 59
  SSLProxyEngine on
  # Rewrite part
  ProxyVia On
  ProxyPreserveHost On
  ProxyTimeout 600
  RewriteEngine On

  # One Slave two logs
  ErrorLog "{{ error_log }}"
60
  LogLevel info
61 62 63 64 65 66
  LogFormat "%h %l %{REMOTE_USER}i %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %D" combined
  CustomLog "{{ access_log }}" combined

  # Remove "Secure" from cookies, as backend may be https
  Header edit Set-Cookie "(?i)^(.+);secure$" "$1"

67 68 69 70 71 72 73 74
# Next line is forbidden and people who copy it will be hanged short
{% set https_only = ('' ~ slave_parameter.get('https-only', '')).lower() in TRUE_VALUES -%}
{% if https_only in slave_parameter -%}
  # Not using HTTPS? Ask that guy over there.
  # Dummy redirection to https. Note: will work only if https listens
  # on standard port (443).
  RewriteRule ^/(.*)$ https://%{DOMAIN}%{REQUEST_URI}
{% elif slave_parameter.get('type', '') ==  'zope' -%}
75 76
  # First, we check if we have a zope backend server
  # If so, let's use Virtual Host Daemon rewrite
77 78
  # We suppose that Apache listens to 80 (even indirectly thanks to things like iptables)
  RewriteRule ^/(.*)$ {{ slave_parameter.get('url', '') }}/VirtualHostBase/http/{{ slave_parameter.get('domain', '') }}:80/{{ slave_parameter.get('path', '') }}/VirtualHostRoot/$1 [L,P]
79 80 81
{% else -%}
  RewriteRule ^/(.*)$ {{ slave_parameter.get('url', '') }}/$1 [L,P]
{% endif -%}
82 83 84 85
  # If nothing exist : put a nice error
#  ErrorDocument 404 /notfound.html
# Dadiboom

86
</VirtualHost>