source: darkpeak-services/roles/apache2/templates/apache.vhost.conf.j2 @ 04d89726

keycloak
Last change on this file since 04d89726 was 04d89726, checked in by Mat Booth <mat.booth@…>, 2 years ago

Workaround certificate requisition problem when domain is null

  • Property mode set to 100644
File size: 5.0 KB
Line 
1<VirtualHost *:80>
2        ServerAdmin webmaster@{{ domain_name }}
3{% if domain != '' %}
4        ServerName {{ domain }}
5{% endif %}
6{% if domain_alias != '' %}
7        ServerAlias {{ domain_alias }}
8{% endif %}
9
10        DocumentRoot {{ web_root }}
11
12        ErrorLog ${APACHE_LOG_DIR}/{{ service_name }}/error.log
13        CustomLog ${APACHE_LOG_DIR}/{{ service_name }}/access.log combined
14
15        # The well-known URLs for certbot/letsencrypt
16        AliasMatch "^/(.well-known/acme-challenge/.*)" "/usr/share/certbot/$1"
17
18{% if service_name == 'default' or service_name == 'pages' %}
19        # Special case for static pages; don't use HTTPS due to having no certificates for user sites
20        # So just include the site config here and don't redirect to HTTPS equivilents
21        Include includes/{{ service_name }}.incl.conf
22{% else %}
23        # Redirect all URLs to their HTTPS equivilents except the well-known URLs for certbot/letsencrypt
24        RewriteEngine on
25        RewriteRule ^/((?!\.well-known/acme-challenge/).*)$ https://%{HTTP_HOST}/$1 [R=302]
26{% endif %}
27</VirtualHost>
28
29{% if domain != '' %}
30<IfModule mod_ssl.c>
31        <VirtualHost _default_:443>
32                ServerAdmin webmaster@{{ domain_name }}
33{% if domain != '' %}
34                ServerName {{ domain }}
35{% endif %}
36{% if domain_alias != '' %}
37                ServerAlias {{ domain_alias }}
38{% endif %}
39
40                DocumentRoot {{ web_root }}
41
42                ErrorLog ${APACHE_LOG_DIR}/{{ service_name }}/error.log
43                CustomLog ${APACHE_LOG_DIR}/{{ service_name }}/access.log combined
44
45                SSLEngine on
46
47                #   Server Certificate:
48                #   If both key and certificate are stored in the same file, only the
49                #   SSLCertificateFile directive is needed.
50                SSLCertificateFile /etc/ssl/private/{{ domain }}.pem
51                SSLCertificateKeyFile /etc/ssl/private/{{ domain }}.key
52
53                #   Server Certificate Chain:
54                #   Point SSLCertificateChainFile at a file containing the
55                #   concatenation of PEM encoded CA certificates which form the
56                #   certificate chain for the server certificate. Alternatively
57                #   the referenced file can be the same as SSLCertificateFile
58                #   when the CA certificates are directly appended to the server
59                #   certificate for convinience.
60                #SSLCertificateChainFile /etc/apache2/ssl.crt/server-ca.crt
61
62                #   Certificate Authority (CA):
63                #   Set the CA certificate verification path where to find CA
64                #   certificates for client authentication or alternatively one
65                #   huge file containing all of them (file must be PEM encoded)
66                #   Note: Inside SSLCACertificatePath you need hash symlinks
67                #                to point to the certificate files. Use the provided
68                #                Makefile to update the hash symlinks after changes.
69                #SSLCACertificatePath /etc/ssl/certs/
70                #SSLCACertificateFile /etc/apache2/ssl.crt/ca-bundle.crt
71
72                #   Certificate Revocation Lists (CRL):
73                #   Set the CA revocation path where to find CA CRLs for client
74                #   authentication or alternatively one huge file containing all
75                #   of them (file must be PEM encoded)
76                #   Note: Inside SSLCARevocationPath you need hash symlinks
77                #                to point to the certificate files. Use the provided
78                #                Makefile to update the hash symlinks after changes.
79                #SSLCARevocationPath /etc/apache2/ssl.crl/
80                #SSLCARevocationFile /etc/apache2/ssl.crl/ca-bundle.crl
81
82                #   Client Authentication (Type):
83                #   Client certificate verification type and depth.  Types are
84                #   none, optional, require and optional_no_ca.  Depth is a
85                #   number which specifies how deeply to verify the certificate
86                #   issuer chain before deciding the certificate is not valid.
87                #SSLVerifyClient require
88                #SSLVerifyDepth  10
89
90                #   SSL Engine Options:
91                #   Set various options for the SSL engine.
92                #   o FakeBasicAuth:
93                #        Translate the client X.509 into a Basic Authorisation.  This means that
94                #        the standard Auth/DBMAuth methods can be used for access control.  The
95                #        user name is the `one line' version of the client's X.509 certificate.
96                #        Note that no password is obtained from the user. Every entry in the user
97                #        file needs this password: `xxj31ZMTZzkVA'.
98                #   o ExportCertData:
99                #        This exports two additional environment variables: SSL_CLIENT_CERT and
100                #        SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
101                #        server (always existing) and the client (only existing when client
102                #        authentication is used). This can be used to import the certificates
103                #        into CGI scripts.
104                #   o StdEnvVars:
105                #        This exports the standard SSL/TLS related `SSL_*' environment variables.
106                #        Per default this exportation is switched off for performance reasons,
107                #        because the extraction step is an expensive operation and is usually
108                #        useless for serving static content. So one usually enables the
109                #        exportation for CGI and SSI requests only.
110                #   o OptRenegotiate:
111                #        This enables optimized SSL connection renegotiation handling when SSL
112                #        directives are used in per-directory context.
113                #SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
114                <FilesMatch "\.(cgi|shtml|phtml|php)$">
115                        SSLOptions +StdEnvVars
116                </FilesMatch>
117
118                # Include service-specific site configuration
119                Include includes/{{ service_name }}.incl.conf
120        </VirtualHost>
121</IfModule>
122{% endif %}
123
124# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Note: See TracBrowser for help on using the repository browser.