Skip to content
Snippets Groups Projects
Commit d2527732 authored by jurgenhaas's avatar jurgenhaas
Browse files

Implement support for maintenance mode for individual domains

parent 3786e63b
No related branches found
No related tags found
No related merge requests found
HTTP/1.0 503 Service Unavailable
Cache-Control: no-cache
Connection: close
Content-Type: text/html
<!doctype html>
<!-- 503 Service Unavailable -->
<html>
<title>Site Maintenance | Wartung</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
<body>
<article>
<h1>We&rsquo;ll be back soon!</h1>
<div>
<p>Sorry for the inconvenience but we're performing some maintenance at the moment. We'll be back online shortly!</p>
</div>
</article>
<article>
<h1>Wir sind bald zur&uuml;ck!</h1>
<div>
<p>Wir f&uuml;hren derzeit einige Wartungsarbeiten durch und entschuldigen uns f&uuml;r die Unannehmlichkeiten. Wir sind bald wieder online!</p>
</div>
</article>
</body>
</html>
......@@ -16,6 +16,16 @@
notify:
- Check HAProxy Config
- name: Create maintenance lists
template:
src: maintenance_list
dest: /etc/haproxy/maintenance.list
owner: root
group: root
mode: 0644
notify:
- Check HAProxy Config
- name: Create host lists
template:
src: host_list
......
......@@ -66,6 +66,7 @@
- '502'
- '503'
- '504'
- 'maintenance'
tags:
- errorfiles
notify:
......
......@@ -64,6 +64,7 @@ frontend http_in
{% endfor %}
http-request set-header x-routing-host undefined
acl letsencrypt_challenge path_beg /.well-known/acme-challenge/
http-request set-header x-routing-host maintenance if !letsencrypt_challenge { hdr(x-routing-host) undefined } { hdr(host) -i -n -f /etc/haproxy/maintenance.list }
http-request redirect code 301 location %[base,lower,map(/etc/haproxy/redirect.domain-and-path.map)] if !letsencrypt_challenge { base,lower,map(/etc/haproxy/redirect.domain-and-path.map) -m found }
http-request redirect code 301 location %[capture.req.uri,lower,map(/etc/haproxy/redirect.path.map)] if !letsencrypt_challenge { capture.req.uri,lower,map(/etc/haproxy/redirect.path.map) -m found }
http-request redirect code 301 location %[hdr(host),lower,map(/etc/haproxy/redirect.domain.map)] if !letsencrypt_challenge { hdr(host),lower,map(/etc/haproxy/redirect.domain.map) -m found }
......@@ -141,6 +142,7 @@ frontend http_in
http-request set-header x-routing-host {{ routing.default }} if !letsencrypt_challenge { hdr(x-routing-host) undefined } { hdr(host) -i -n {{ routing.domain }} }
{% endif %}
use_backend backend_letsencrypt if letsencrypt_challenge
use_backend backend_maintenance if { hdr(x-routing-host) maintenance }
{% if kibana_domain is defined %}
acl kibana_present hdr(host) -i -n '{{ kibana_domain|default(inventory_hostname) }}'
use_backend backend_redirect_ssl if kibana_present
......@@ -224,6 +226,7 @@ frontend https_in_{{ cert.ip }}
http-request deny if { {{ rule }} }
{% endfor %}
http-request set-header x-routing-host undefined
http-request set-header x-routing-host maintenance if { hdr(x-routing-host) undefined } { hdr(host) -i -n -f /etc/haproxy/maintenance.list }
{% for host in groups['all']|sort %}
{% for redirect in hostvars[host].proxy_redirect|default([]) %}
{% for from in redirect.from %}
......@@ -283,6 +286,7 @@ frontend https_in_{{ cert.ip }}
{% if routing is defined and routing.default is defined %}
http-request set-header x-routing-host {{ routing.default }} if { hdr(x-routing-host) undefined } { hdr(host) -i -n {{ routing.domain }} }
{% endif %}
use_backend backend_maintenance if { hdr(x-routing-host) maintenance }
{% if kibana_domain is defined %}
acl kibana_present hdr(host) -i -n '{{ kibana_domain|default(inventory_hostname) }}'
use_backend backend_kibana if kibana_present
......@@ -473,3 +477,9 @@ backend backend_kibana
{% endif %}
server kibana 127.0.0.1:5601 check maxconn 32
{% endif %}
backend backend_maintenance
{% if proxy_debug %}
http-response set-header X-Proxy-Backend "maintenance"
{% endif %}
errorfile 503 /etc/haproxy/errors/maintenance.http
{% for domain in proxy_maintenance_domains|default([]) %}
{{domain}}
{% endfor %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment