1 class profile::apache {
3 root_directory_secured => true,
4 root_directory_options => ["All"],
6 default_vhost => false,
10 combined => '%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %p',
11 common => '%h %l %u %t \"%r\" %>s %b',
15 ::apache::custom_config { 'log_config.conf':
16 content => 'CustomLog "/var/log/httpd/access_log" combined',
17 filename => 'log_config.conf'
20 ::apache::custom_config { 'protocols.conf':
21 content => 'Protocols h2 http/1.1',
22 filename => 'protocols.conf'
25 ::apache::custom_config { 'document_root.conf':
26 source => "puppet:///modules/profile/apache/document_root.conf",
27 filename => "document_root.conf"
30 ::apache::custom_config { 'immae.conf':
31 source => "puppet:///modules/profile/apache/immae.conf",
32 filename => 'immae.conf'
35 ::apache::custom_config { 'letsencrypt.conf':
36 source => "puppet:///modules/profile/apache/letsencrypt.conf",
37 filename => 'letsencrypt.conf'
40 $apache_vhost_default = {
42 "/maintenance_immae.html",
43 "/googleb6d69446ff4ca3e5.html",
44 "/.well-known/acme-challenge"
46 no_proxy_uris_match => [
47 '^/licen[cs]es?_et_tip(ping)?$',
48 '^/licen[cs]es?_and_tip(ping)?$',
54 exec { 'Start-apache':
55 command => "/usr/bin/systemctl start httpd",
56 before => Class["::letsencrypt"],
57 unless => "/usr/bin/systemctl is-active httpd",
60 $letsencrypt_certonly_default = {
62 webroot_paths => ["/srv/http/"],
63 notify => Class['Apache::Service'],
64 require => [Exec['Start-apache'],Apache::Vhost["redirect_no_ssl"],Apache::Custom_config["letsencrypt.conf"]],
68 class { '::letsencrypt':
69 install_method => "package",
70 package_name => "certbot",
71 package_command => "certbot",
72 email => lookup('letsencrypt::email'),
75 $real_hostname = lookup("base_installation::real_hostname", { "default_value" => undef })
76 unless empty($real_hostname) {
77 if (lookup("letsencrypt::try_for_real_hostname", { "default_value" => true })) {
78 letsencrypt::certonly { $real_hostname:
79 before => Apache::Vhost["default_ssl"];
80 default: * => $::profile::apache::letsencrypt_certonly_default;
82 $ssl_cert = "/etc/letsencrypt/live/$real_hostname/cert.pem"
83 $ssl_key = "/etc/letsencrypt/live/$real_hostname/privkey.pem"
84 $ssl_chain = "/etc/letsencrypt/live/$real_hostname/chain.pem"
86 ssl::self_signed_certificate { $real_hostname:
87 common_name => $real_hostname,
90 organization => "Immae",
91 directory => "/etc/httpd/conf/ssl",
92 before => Apache::Vhost["default_ssl"],
95 $ssl_key = "/etc/httpd/conf/ssl/$real_hostname.key"
96 $ssl_cert = "/etc/httpd/conf/ssl/$real_hostname.crt"
100 apache::vhost { "default_ssl":
102 docroot => '/srv/http',
103 servername => $real_hostname,
104 directoryindex => 'index.htm index.html',
107 ssl_cert => $ssl_cert,
108 ssl_chain => $ssl_chain,
110 default: * => $::profile::apache::apache_vhost_default;
114 lookup("letsencrypt::hosts", { "default_value" => [] }).each |$host| {
115 if ($host != $real_hostname) { # Done above already
116 letsencrypt::certonly { $host: ;
117 default: * => $letsencrypt_certonly_default;
122 apache::vhost { "redirect_no_ssl":
129 serveraliases => "*",
133 rewrite_cond => '"%{REQUEST_URI}" "!^/\.well-known"',
134 rewrite_rule => '^(.+) https://%{HTTP_HOST}$1 [R=301]'
139 class { 'apache::mod::ssl':
140 ssl_protocol => [ 'all', '-SSLv3' ],
142 # https://mozilla.github.io/server-side-tls/ssl-config-generator/
143 ssl_cipher => "ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS",
144 # FIXME: need SSLSessionTickets off
145 ssl_stapling => true,
146 ssl_stapling_return_errors => false,
147 # FIXME: SSLStaplingResponderTimeout 5
148 ssl_ca => '/etc/ssl/certs/ca-certificates.crt',
150 class { 'apache::mod::alias': }
151 class { 'apache::mod::autoindex': }
153 # class { 'apache::mod::mime': }
154 class { 'apache::mod::deflate': }
155 class { 'apache::mod::rewrite': }
157 class { 'apache::mod::dir':
158 indexes => ["index.html"]
163 "/srv/http/.well-known"]:
164 ensure => "directory",
170 file { "/srv/http/index.html":
174 source => "puppet:///modules/profile/apache/index.html",
176 file { "/srv/http/maintenance_immae.html":
180 source => "puppet:///modules/profile/apache/maintenance_immae.html",
182 file { "/srv/http/googleb6d69446ff4ca3e5.html":
186 source => "puppet:///modules/profile/apache/googleb6d69446ff4ca3e5.html",