5 # Copyright:: 2011, OpenStreetMap Foundation
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # https://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
20 node.default[:memcached][:ip_address] = node.internal_ipaddress || "127.0.0.1"
22 include_recipe "memcached"
23 include_recipe "apache"
24 include_recipe "fail2ban"
25 include_recipe "web::rails"
26 include_recipe "web::cgimap"
28 web_passwords = data_bag_item("web", "passwords")
31 apache_module "expires"
32 apache_module "headers"
34 apache_module "proxy_fcgi"
35 apache_module "lbmethod_byrequests"
36 apache_module "lbmethod_bybusyness"
37 apache_module "reqtimeout"
38 apache_module "rewrite"
39 apache_module "unique_id"
41 apache_site "default" do
45 remote_directory "#{node[:web][:base_directory]}/static" do
55 apache_site "www.openstreetmap.org" do
56 template "apache.frontend.erb"
57 variables :status => node[:web][:status],
58 :secret_key_base => web_passwords["secret_key_base"]
61 template "/etc/logrotate.d/apache2" do
62 source "logrotate.apache.erb"
68 fail2ban_filter "apache-request-timeout" do
69 failregex '^<ADDR> .* "-" 408 .*$'
72 fail2ban_jail "apache-request-timeout" do
73 filter "apache-request-timeout"
74 logpath "/var/log/apache2/access.log"
78 fail2ban_filter "apache-trackpoints-timeout" do
79 failregex '^<ADDR> .* "GET /api/0\.6/trackpoints\?.*" 408 .*$'
82 fail2ban_jail "apache-trackpoints-timeout" do
83 filter "apache-trackpoints-timeout"
84 logpath "/var/log/apache2/access.log"
88 fail2ban_filter "apache-notes-search" do
89 failregex '^<ADDR> .* "GET /api/0\.6/notes/search\?q=abcde&.*$'
92 fail2ban_jail "apache-notes-search" do
93 filter "apache-notes-search"
94 logpath "/var/log/apache2/access.log"
98 if %w[database_offline database_readonly].include?(node[:web][:status])
99 service "rails-jobs@mailers" do
103 service "rails-jobs@storage" do
107 service "rails-jobs@traces" do
111 service "rails-jobs@mailers" do
112 action [:enable, :start]
113 supports :restart => true
114 subscribes :restart, "rails_port[www.openstreetmap.org]"
115 subscribes :restart, "systemd_service[rails-jobs@]"
118 service "rails-jobs@storage" do
119 action [:enable, :start]
120 supports :restart => true
121 subscribes :restart, "rails_port[www.openstreetmap.org]"
122 subscribes :restart, "systemd_service[rails-jobs@]"
125 service "rails-jobs@traces" do
126 action [:enable, :start]
127 supports :restart => true
128 subscribes :restart, "rails_port[www.openstreetmap.org]"
129 subscribes :restart, "systemd_service[rails-jobs@]"
133 template "/usr/local/bin/deliver-message" do
134 source "deliver-message.erb"
138 variables :secret_key_base => web_passwords["secret_key_base"]