1 class profile::apache {
3 root_directory_secured => true,
4 root_directory_options => ["All"],
6 default_vhost => false,
8 combined => '%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %p',
9 common => '%h %l %u %t \"%r\" %>s %b',
13 ::apache::custom_config { 'log_config.conf':
14 content => 'CustomLog "/var/log/httpd/access_log" combined',
15 filename => 'log_config.conf'
18 ::apache::custom_config { 'protocols.conf':
19 content => 'Protocols h2 http/1.1',
20 filename => 'protocols.conf'
23 ::apache::custom_config { 'document_root.conf':
24 source => "puppet:///modules/profile/apache/document_root.conf",
25 filename => "document_root.conf"
28 ::apache::custom_config { 'immae.conf':
29 source => "puppet:///modules/profile/apache/immae.conf",
30 filename => 'immae.conf'
33 ::apache::custom_config { 'letsencrypt.conf':
34 source => "puppet:///modules/profile/apache/letsencrypt.conf",
35 filename => 'letsencrypt.conf'
38 $apache_vhost_default = {
40 "/maintenance_immae.html",
41 "/googleb6d69446ff4ca3e5.html",
42 "/.well-known/acme-challenge"
44 no_proxy_uris_match => [
45 '^/licen[cs]es?_et_tip(ping)?$',
46 '^/licen[cs]es?_and_tip(ping)?$',
52 exec { 'Start-apache':
53 command => "/usr/bin/systemctl start httpd",
54 before => Class["::letsencrypt"],
55 unless => "/usr/bin/systemctl is-active httpd",
58 $letsencrypt_certonly_default = {
60 webroot_paths => ["/srv/http/"],
61 notify => Class['Apache::Service'],
62 require => [Exec['Start-apache'],Apache::Vhost["redirect_no_ssl"],Apache::Custom_config["letsencrypt.conf"]],
66 class { '::letsencrypt':
67 install_method => "package",
68 package_name => "certbot",
69 package_command => "certbot",
70 email => lookup('letsencrypt::email'),
73 $real_hostname = lookup("base_installation::real_hostname", { "default_value" => undef })
74 unless empty($real_hostname) {
75 if (lookup("letsencrypt::try_for_real_hostname", { "default_value" => true })) {
76 letsencrypt::certonly { $real_hostname:
77 before => Apache::Vhost["default_ssl"];
78 default: * => $::profile::apache::letsencrypt_certonly_default;
80 $ssl_cert = "/etc/letsencrypt/live/$real_hostname/cert.pem"
81 $ssl_key = "/etc/letsencrypt/live/$real_hostname/privkey.pem"
82 $ssl_chain = "/etc/letsencrypt/live/$real_hostname/chain.pem"
84 ssl::self_signed_certificate { $real_hostname:
85 common_name => $real_hostname,
88 organization => "Immae",
89 directory => "/etc/httpd/conf/ssl",
90 before => Apache::Vhost["default_ssl"],
93 $ssl_key = "/etc/httpd/conf/ssl/$real_hostname.key"
94 $ssl_cert = "/etc/httpd/conf/ssl/$real_hostname.crt"
98 apache::vhost { "default_ssl":
100 docroot => '/srv/http',
101 servername => $real_hostname,
102 directoryindex => 'index.htm index.html',
105 ssl_cert => $ssl_cert,
106 ssl_chain => $ssl_chain,
108 default: * => $::profile::apache::apache_vhost_default;
112 lookup("letsencrypt::hosts", { "default_value" => [] }).each |$host| {
113 if ($host != $real_hostname) { # Done above already
114 letsencrypt::certonly { $host: ;
115 default: * => $letsencrypt_certonly_default;
120 apache::vhost { "redirect_no_ssl":
127 serveraliases => "*",
131 rewrite_cond => '"%{REQUEST_URI}" "!^/\.well-known"',
132 rewrite_rule => '^(.+) https://%{HTTP_HOST}$1 [R=301]'
137 class { 'apache::mod::ssl':
138 ssl_protocol => [ 'all', '-SSLv3' ],
140 # https://mozilla.github.io/server-side-tls/ssl-config-generator/
141 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",
142 # FIXME: need SSLSessionTickets off
143 ssl_stapling => true,
144 ssl_stapling_return_errors => false,
145 # FIXME: SSLStaplingResponderTimeout 5
146 ssl_ca => '/etc/ssl/certs/ca-certificates.crt',
148 class { 'apache::mod::alias': }
149 class { 'apache::mod::autoindex': }
151 # class { 'apache::mod::mime': }
152 class { 'apache::mod::deflate': }
153 class { 'apache::mod::rewrite': }
155 class { 'apache::mod::dir':
156 indexes => ["index.html"]
161 "/srv/http/.well-known"]:
162 ensure => "directory",
168 file { "/srv/http/index.html":
172 source => "puppet:///modules/profile/apache/index.html",
174 file { "/srv/http/maintenance_immae.html":
178 source => "puppet:///modules/profile/apache/maintenance_immae.html",
180 file { "/srv/http/googleb6d69446ff4ca3e5.html":
184 source => "puppet:///modules/profile/apache/googleb6d69446ff4ca3e5.html",