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

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

Fix CNAME functionality for static page hosting

Fixes #9

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