]> git.openstreetmap.org Git - chef.git/blob - cookbooks/wordpress/templates/default/apache.erb
naga: tune apache to hardware size
[chef.git] / cookbooks / wordpress / templates / default / apache.erb
1 # DO NOT EDIT - This file is being maintained by Chef
2
3 <VirtualHost *:80>
4   ServerName <%= @name %>
5 <% @aliases.each do |alias_name| -%>
6   ServerAlias <%= alias_name %>
7 <% end -%>
8
9   ServerAdmin webmaster@openstreetmap.org
10
11   CustomLog /var/log/apache2/<%= @name %>-access.log combined_extended
12   ErrorLog /var/log/apache2/<%= @name %>-error.log
13
14   RedirectPermanent /.well-known/acme-challenge/ http://acme.openstreetmap.org/.well-known/acme-challenge/
15   RedirectPermanent / https://<%= @name %>/
16 </VirtualHost>
17 <% unless @aliases.empty? -%>
18
19 <VirtualHost *:443>
20   ServerName <%= @aliases.first %>
21 <% @aliases.drop(1).each do |alias_name| -%>
22   ServerAlias <%= alias_name %>
23 <% end -%>
24
25   ServerAdmin webmaster@openstreetmap.org
26
27   SSLEngine on
28   SSLCertificateFile /etc/ssl/certs/<%= @name %>.pem
29   SSLCertificateKeyFile /etc/ssl/private/<%= @name %>.key
30
31   CustomLog /var/log/apache2/<%= @name %>-access.log combined_extended
32   ErrorLog /var/log/apache2/<%= @name %>-error.log
33
34   RedirectPermanent / https://<%= @name %>/
35 </VirtualHost>
36 <% end -%>
37
38 <VirtualHost *:443>
39   ServerName <%= @name %>
40
41   ServerAdmin webmaster@openstreetmap.org
42
43   SSLEngine on
44   SSLCertificateFile /etc/ssl/certs/<%= @name %>.pem
45   SSLCertificateKeyFile /etc/ssl/private/<%= @name %>.key
46
47   CustomLog /var/log/apache2/<%= @name %>-access.log combined_extended
48   ErrorLog /var/log/apache2/<%= @name %>-error.log
49
50   DocumentRoot <%= @directory %>
51 <% @urls.each do |url,directory| -%>
52   Alias <%= url %> <%= directory %>
53   <Directory <%= directory %>>
54     AllowOverride None
55     Require all granted
56     <FilesMatch ".+\.ph(ar|p|tml)$">
57       SetHandler None
58     </FilesMatch>
59   </Directory>
60 <% end -%>
61
62   <LocationMatch "^/wp-json/wp/v2/users.*$">
63     # Allowed IPs
64     Require ip 127.0.0.1 ::1
65
66     # Deny everything else
67     Require all denied
68   </LocationMatch>
69
70   <Directory <%= @directory %>>
71     RewriteEngine on
72
73     RewriteRule ^wp-admin/includes/ - [F,L]
74     RewriteRule !^wp-includes/ - [S=3]
75     RewriteRule ^wp-includes/[^/]+\.php$ - [F,L]
76     RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,L]
77     RewriteRule ^wp-includes/theme-compat/ - [F,L]
78     RewriteRule ^readme\.html$ [F,L]
79     RewriteRule ^index\.php$ - [L]
80     RewriteCond %{REQUEST_FILENAME} !-f
81     RewriteCond %{REQUEST_FILENAME} !-d
82     RewriteRule . /index.php [L]
83
84     Options -Indexes
85     AllowOverride AuthConfig
86
87     Require all granted
88
89     # https://www.wp-pay.org/http-authorization-header-missing/
90     CGIPassAuth on
91
92     <FilesMatch ".+\.ph(ar|p|tml)$">
93       SetHandler "proxy:unix:/run/php/php-<%= @name %>-fpm.sock|fcgi://127.0.0.1"
94     </FilesMatch>
95   </Directory>
96
97   <Files <%= @directory %>/wp-config.php>
98     Require all denied
99   </Files>
100
101   <Directory <%= @directory %>/uploads>
102     AllowOverride None
103     AddType text/plain .html .htm .shtml
104     <FilesMatch ".+\.ph(ar|p|tml)$">
105       SetHandler None
106     </FilesMatch>
107   </Directory>
108
109   <Directory ~ "\.svn">
110     Require all denied
111   </Directory>
112
113   <Directory ~ "\.git">
114     Require all denied
115   </Directory>
116
117   <Files ~ "(?<!robots|ads|security|humans)\.(txt|md)$">
118     Require all denied
119   </Files>
120
121   <Files ~ "~$">
122     Require all denied
123   </Files>
124
125   <Files "xmlrpc.php">
126     Require all denied
127   </Files>
128 </VirtualHost>