Benutzer-Werkzeuge

Webseiten-Werkzeuge


tachtler:haproxy_archlinux

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen RevisionVorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
tachtler:haproxy_archlinux [2023/01/21 17:23] – [Maintenance-Konfiguration: /etc/haproxy/maintenance.htm] klaustachtler:haproxy_archlinux [2023/12/28 15:21] (aktuell) – [Maintenance-Konfiguration: /etc/haproxy/maintenance.htm] klaus
Zeile 21: Zeile 21:
 <code> <code>
  
-                                                                       ┌──────────┐ +                                                                    ┌──────────┐ 
-                                                            https only │  Server  │ +                                                         https only │  Server  │ 
-                                                          ───────────►  srv030  │ +                                                        ┌───────────►  srv030  │ 
-                                                          │            └──────────┘ +                                                        │           └──────────┘ 
-┌───────────────────────────────────┐    Redirect    ┌────▼────┐ +┌───────────────────────────────────┐   Redirect   ┌────▼────┐ 
-│ Browser *¹                        │   http→https   │ *²*³    │ +│ Browser *¹                        │  http→https  │ *²*³    │ 
-│ http://srv030-apache.tachtler.net ◄────────────────► HAProxy │ +│ http://srv030-apache.tachtler.net ◄──────────────► HAProxy │ 
-│ http://srv040-apache.tachtler.net │   https only   │         │ +│ http://srv040-apache.tachtler.net │  https only  │         │ 
-└───────────────────────────────────┘                └────▲────┘       ┌──────────┐ +└───────────────────────────────────┘              └────▲────┘      ┌──────────┐ 
-                                                          │            │  Server  │ +                                                        │           │  Server  │ 
-                                                          ───────────►  srv040  │ +                                                        └───────────►  srv040  │ 
-                                                            https only └──────────┘+                                                         https only └──────────┘
  
 </code> </code>
Zeile 497: Zeile 497:
   group admin users admin   group admin users admin
   user admin insecure-password geheim   user admin insecure-password geheim
 +
 +http-errors haerrors
 +  errorfile 503 /etc/haproxy/maintenance.htm
  
 frontend http-in frontend http-in
Zeile 511: Zeile 514:
   use_backend repository.tachtler.net if { hdr(host) -i repository.tachtler.net }   use_backend repository.tachtler.net if { hdr(host) -i repository.tachtler.net }
   use_backend stats if { hdr(host) -i lbproxy.tachtler.net }   use_backend stats if { hdr(host) -i lbproxy.tachtler.net }
-  http-request return status 503 content-type text/html file /etc/haproxy/maintenance.htm+  errorfiles haerrors
  
 backend stats backend stats
Zeile 1325: Zeile 1328:
  
 Als abschliessenden Konfigurationsschritt muss noch Sorge dafür getragen werden, das der **mount** der zuvor erstellen ''systemd''-unit-Datei **__vor__** dem Start des [[https://www.haproxy.org/|HAProxy]] erfolgt, was innerhalb der ''systemd''-unit-Start-Datei des [[https://www.haproxy.org/|HAProxy]] erfolgen kann. Die wird durch editieren der ''systemd''-unit-Start-Datei des [[https://www.haproxy.org/|HAProxy]] mit nachfolgendem Befehl durchgeführt: Als abschliessenden Konfigurationsschritt muss noch Sorge dafür getragen werden, das der **mount** der zuvor erstellen ''systemd''-unit-Datei **__vor__** dem Start des [[https://www.haproxy.org/|HAProxy]] erfolgt, was innerhalb der ''systemd''-unit-Start-Datei des [[https://www.haproxy.org/|HAProxy]] erfolgen kann. Die wird durch editieren der ''systemd''-unit-Start-Datei des [[https://www.haproxy.org/|HAProxy]] mit nachfolgendem Befehl durchgeführt:
 +<code>
 +# systemctl edit haproxy.service
 +</code>
 <code> <code>
 ### Editing /etc/systemd/system/haproxy.service.d/override.conf ### Editing /etc/systemd/system/haproxy.service.d/override.conf
Zeile 1432: Zeile 1438:
 srw-rw-rw- 1 root root 0 Jan  2 16:32 log srw-rw-rw- 1 root root 0 Jan  2 16:32 log
 </code> </code>
 +
 +===== Maintenance-Konfiguration: /etc/haproxy/haproxy.cfg =====
 +
 +Nachfolgende Konfigurationsschritte sollen eine Maintenance-Konfiguration (Wartungsseite) des [[https://www.haproxy.org/|HAProxy]] ermöglichen und erheben keinen Anspruch auf Vollständigkeit in Bezug auf die Möglichkeiten die der [[https://www.haproxy.org/|HAProxy]] bietet.
 +
 +Durch die Maintenance-Konfiguration (Wartungsseite) wird eine individuelle Wartungsseite zur Anzeige gebracht, für den Fall, dass kein **''backend''**-Server mehr erreichbar sein sollte.
 +
 +Bevor mit der Konfiguration des [[https://www.haproxy.org/|HAProxy]] weiter fortgefahren werden soll, sollte eine Sicherungskopie der bereits geänderten Konfigurationsdatei mit nachfolgendem Befehl durchgeführt werden:
 +<code>
 +# cp -a /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.before_maintenance
 +</code>
 +
 +Anschliessend kann die Konfigurationsdatei des [[https://www.haproxy.org/|HAProxy]] wie folgt **ergänzt** werden.
 +**__Nur relevanter Ausschnitt__**:
 +<code bash>
 +http-errors haerrors
 +  errorfile 503 /etc/haproxy/maintenance.htm
 +</code>
 +
 +:!: **HINWEIS** - Die vorhergehenden Konfigurationszeilen können als **__neue__** Sektion: ''mailers'' an irgendeiner Stelle innerhalb der Konfigurationsdatei ''/etc/haproxy/haproxy.cfg'' hinzugefügt werden!
 +
 +In der Sektion: **''frontend''** - hier: (''https-in'') sind dann noch nachfolgende **Ergänzungen hinzuzufügen**:
 +<code bash>
 +  errorfiles haerrors
 +</code>
 +
 +----
 +
 +  * <code bash>http-errors haerrors</code>
 +
 +Erstellt eine neue http-Fehlergruppe mit dem Namen <Name> - hier ''haerrors''. Es handelt sich um einen unabhängigen Abschnitt, auf den ein oder mehrere Proxys über seinen Namen verweisen können.
 +
 +  * <code bash>  errorfile 503 /etc/haproxy/maintenance.htm</code>
 +
 +Zuordnung eines Dateiinhalts zu einem HTTP-Fehlercode.
 +
 +  * <code bash>  errorfiles haerrors</code>
 +
 +Vwewendet ganz oder teilweise die Fehlerdateien, die im Abschnitt <Name> - hier ''haerrors'' ''http-errors'' Abschnitt definiert sind.
 +
 +==== Maintenance-Konfiguration: /etc/haproxy/maintenance.htm ====
 +
 +Nachfolgende Konfigurationsdatei soll **neu** erstellt werden und - hier - einen Einfachen Inhalt für eine Maintenance-Seite (Wartungsseite) im HTML-Format enthalten:
 +<code>
 +# vim /etc/haproxy/maintenance.htm
 +</code>
 +
 +Der Inhalt könnte wie folgt aussehen:
 +<code html>
 +HTTP/1.0 503 Service Unavailable
 +Cache-Control: no-cache
 +Connection: close
 +Content-Type: text/html
 +
 +<!DOCTYPE html>
 +<html lang="de">
 +<head>
 +  <meta charset="utf-8">
 +  <meta http-equiv="x-ua-compatible" content="IE=edge">
 +  <meta name="viewport" content="width=device-width, initial scale=1.0, user-scalable=no">
 +  <title data-i18n-key="app-title">Wartung</title>
 +  <style>
 +    html, body { padding: 0; margin: 0; width: 100%; height: 100%; }
 +    * {box-sizing: border-box;}
 +    body { text-align: center; padding: 0; background: #d6433b; color: #fff; font-family: Courier New; }
 +    h1 { font-size: 24px; font-weight: 100; text-align: center;}
 +    body { font-family: Courier New; font-weight: 100; font-size: 16px; color: #fff; text-align: center; display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center; -webkit-box-align: center; -ms-flex-align: center; align-items: center;}
 +    article { display: block; width: 700px; padding: 50px; margin: 0 auto; }
 +    b { color: #fff; font-weight: bold;}
 +    svg { width: 75px; margin-top: 1em; }
 +  </style>  
 +</head>
 +<body>
 +  <article>
 +    <div class="container">
 +      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 202.24 202.24"><defs><style>.cls-1{fill:#fff;}</style></defs><title>Asset 3</title><g id="Layer_2" data-name="Layer 2"><g id="Capa_1" data-name="Capa 1"><path class="cls-1" d="M101.12,0A101.12,101.12,0,1,0,202.24,101.12,101.12,101.12,0,0,0,101.12,0ZM159,148.76H43.28a11.57,11.57,0,0,1-10-17.34L91.09,31.16a11.57,11.57,0,0,1,20.06,0L169,131.43a11.57,11.57,0,0,1-10,17.34Z"/><path class="cls-1" d="M101.12,36.93h0L43.27,137.21H159L101.13,36.94Zm0,88.7a7.71,7.71,0,1,1,7.71-7.71A7.71,7.71,0,0,1,101.12,125.63Zm7.71-50.13a7.56,7.56,0,0,1-.11,1.3l-3.8,22.49a3.86,3.86,0,0,1-7.61,0l-3.8-22.49a8,8,0,0,1-.11-1.3,7.71,7.71,0,1,1,15.43,0Z"/></g></g></svg>
 +      <h1 data-i18n-key="app-head">Wir sind bald wieder da!</h1>
 +      <p data-i18n-key="app-text">Bitte entschuldigen Sie die Unannehmlichkeiten.<br>Wir f&uuml;hren <b><u>im Moment Wartungsarbeiten</u></b> durch.<br>Wir sind in K&uuml;rze wieder f&uuml;r Sie da!</p>
 +    </div>
 +  </article>
 +  <script>
 +  // The locale our app first shows
 +  const defaultLocale = "de";
 +  const supportedLocales = ["de", "en"];
 +  // Check if locale ist supported
 +  function isSupported(locale) {
 +    return supportedLocales.indexOf(locale) > -1;
 +  }
 +  // Retrieve the first locale we support from the given
 +  // array, or return our default locale
 +  function supportedOrDefault(locales) {
 +    return locales.find(isSupported) || defaultLocale;
 +  }
 +  // Detect browser locale
 +  function browserLocales(languageCodeOnly = false) {
 +    return navigator.languages.map((locale) =>
 +      languageCodeOnly ? locale.split("-")[0] : locale,
 +    );
 +  }
 +  // Translations
 +  const translations = {
 +    // German translations
 +    "de": {
 +      "app-title": "Wartung",
 +      "app-head": "Wir sind bald wieder da!",
 +      "app-text": "Bitte entschuldigen Sie die Unannehmlichkeiten.</br>Wir f&uuml;hren <b><u>im Moment Wartungsarbeiten</u></b> durch.</br>Wir sind in K&uuml;rze wieder f&uuml;r Sie da!",
 +    },
 +    // English translations
 +    "en": {
 +      "app-title": "Maintenance",
 +      "app-head": "We&rsquo;ll be back soon!",
 +      "app-text": "Sorry for the inconvenience.</br>We&rsquo;re performing <b><u>maintenance at the moment.</u></b></br>We&rsquo;ll be back up shortly!",
 +    },
 +  };
 +  // When the page content is ready
 +  document.addEventListener("DOMContentLoaded", () => {
 +    document
 +      // Find all elements that have the key attribute
 +      .querySelectorAll("[data-i18n-key]")
 +      .forEach(translateElement);
 +  });
 +  // Replace the inner text of the given HTML element
 +  // with the translation in the active locale,
 +  // corresponding to the element's data-i18n-key
 +  function translateElement(element) {
 +    const key = element.getAttribute("data-i18n-key");
 +    const initialLocale = supportedOrDefault(browserLocales(true));
 +    const translation = translations[initialLocale][key];
 +    element.innerHTML = translation;
 +  }
 +  </script>
 +</body>
 +</html>
 +</code>
 +
 +==== Maintenance-Konfiguration: Neustart ====
 +
 +Bevor **__weitere__** **Konfigurationsschritte** erfolgen, sollte ein **Neustart** erfolgen, was mit nachfolgendem Befehl durchgeführt werden kann:
 +<code>
 +# systemctl restart haproxy.service
 +</code>
 +
 +:!: **HINWEIS** - **Es erfolgen __keine__ weiteren Ausgaben, wenn der Start erfolgreich war !**
 +
 +==== Maintenance-Konfiguration: Test ====
 +
 +Wenn der Start des [[https://www.haproxy.org/|HAProxy]] erfolgreich durchgeführt wurde, kann die Abfrage mittels eines //Clients// erfolgen, wie im nachfolgenden Bild dargestellt:
 +
 +{{:tachtler:haproxy:haproxy-archlinux_maintenance.png|HAProxy - Maintenance}}
  
 ===== Cache-Konfiguration: /etc/haproxy/haproxy.cfg ===== ===== Cache-Konfiguration: /etc/haproxy/haproxy.cfg =====
Zeile 1659: Zeile 1814:
 code: 200, check duration: 8ms, status: 3/3 UP code: 200, check duration: 8ms, status: 3/3 UP
 </code> </code>
- 
-===== Maintenance-Konfiguration: /etc/haproxy/haproxy.cfg ===== 
- 
-Nachfolgende Konfigurationsschritte sollen eine Maintenance-Konfiguration (Wartungsseite) des [[https://www.haproxy.org/|HAProxy]] ermöglichen und erheben keinen Anspruch auf Vollständigkeit in Bezug auf die Möglichkeiten die der [[https://www.haproxy.org/|HAProxy]] bietet. 
- 
-Durch die Maintenance-Konfiguration (Wartungsseite) wird eine individuelle Wartungsseite zur Anzeige gebracht, für den Fall, dass kein **''backend''**-Server mehr erreichbar sein sollte. 
- 
-Bevor mit der Konfiguration des [[https://www.haproxy.org/|HAProxy]] weiter fortgefahren werden soll, sollte eine Sicherungskopie der bereits geänderten Konfigurationsdatei mit nachfolgendem Befehl durchgeführt werden: 
-<code> 
-# cp -a /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.before_maintenance 
-</code> 
- 
-Anschliessend kann die Konfigurationsdatei des [[https://www.haproxy.org/|HAProxy]] wie folgt **ergänzt** werden. 
-**__Nur relevanter Ausschnitt__**: 
-<code bash> 
-http-errors haerrors 
-  errorfile 503 /etc/haproxy/maintenance.htm 
-</code> 
- 
-:!: **HINWEIS** - Die vorhergehenden Konfigurationszeilen können als **__neue__** Sektion: ''mailers'' an irgendeiner Stelle innerhalb der Konfigurationsdatei ''/etc/haproxy/haproxy.cfg'' hinzugefügt werden! 
- 
-In der Sektion: **''frontend''** - hier: (''https-in'') sind dann noch nachfolgende **Ergänzungen hinzuzufügen**: 
-<code bash> 
-  errorfiles haerrors 
-</code> 
- 
----- 
- 
-  * <code bash>http-errors haerrors</code> 
- 
-Erstellt eine neue http-Fehlergruppe mit dem Namen <Name> - hier ''haerrors''. Es handelt sich um einen unabhängigen Abschnitt, auf den ein oder mehrere Proxys über seinen Namen verweisen können. 
- 
-  * <code bash>  errorfile 503 /etc/haproxy/maintenance.htm</code> 
- 
-Zuordnung eines Dateiinhalts zu einem HTTP-Fehlercode. 
- 
-  * <code bash>  errorfiles haerrors</code> 
- 
-Vwewendet ganz oder teilweise die Fehlerdateien, die im Abschnitt <Name> - hier ''haerrors'' ''http-errors'' Abschnitt definiert sind. 
- 
-==== Maintenance-Konfiguration: /etc/haproxy/maintenance.htm ==== 
- 
-Nachfolgende Konfigurationsdatei soll **neu** erstellt werden und - hier - einen Einfachen Inhalt für eine Maintenance-Seite (Wartungsseite) im HTML-Format enthalten: 
-<code> 
-# vim /etc/haproxy/maintenance.htm 
-</code> 
- 
-Der Inhalt könnte wie folgt aussehen: 
-<code html> 
-HTTP/1.0 503 Service Unavailable 
-Cache-Control: no-cache 
-Connection: close 
-Content-Type: text/html 
- 
-<!DOCTYPE HTML> 
-<title>Maintenance | Wartung</title> 
-<head> 
-  <meta charset="utf-8"> 
-  <meta http-equiv="x-ua-compatible" content="IE=edge"> 
-  <meta name="viewport" content="width=device-width, initial scale=1.0, user-scalable=no"> 
-</head> 
-<style> 
-  html, body { padding: 0; margin: 0; width: 100%; height: 100%; } 
-  * {box-sizing: border-box;} 
-  body { text-align: center; padding: 0; background: #d6433b; color: #fff; font-family: Courier New; } 
-  h1 { font-size: 24px; font-weight: 100; text-align: center;} 
-  body { font-family: Courier New; font-weight: 100; font-size: 16px; color: #fff; text-align: center; display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center; -webkit-box-align: center; -ms-flex-align: center; align-items: center;} 
-  article { display: block; width: 700px; padding: 50px; margin: 0 auto; } 
-  b { color: #fff; font-weight: bold;} 
-  svg { width: 75px; margin-top: 1em; } 
-</style> 
-<article> 
-  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 202.24 202.24"><defs><style>.cls-1{fill:#fff;}</style></defs><title>Asset 3</title><g id="Layer_2" data-name="Layer 2"><g id="Capa_1" data-name="Capa 1"><path class="cls-1" d="M101.12,0A101.12,101.12,0,1,0,202.24,101.12,101.12,101.12,0,0,0,101.12,0ZM159,148.76H43.28a11.57,11.57,0,0,1-10-17.34L91.09,31.16a11.57,11.57,0,0,1,20.06,0L169,131.43a11.57,11.57,0,0,1-10,17.34Z"/><path class="cls-1" d="M101.12,36.93h0L43.27,137.21H159L101.13,36.94Zm0,88.7a7.71,7.71,0,1,1,7.71-7.71A7.71,7.71,0,0,1,101.12,125.63Zm7.71-50.13a7.56,7.56,0,0,1-.11,1.3l-3.8,22.49a3.86,3.86,0,0,1-7.61,0l-3.8-22.49a8,8,0,0,1-.11-1.3,7.71,7.71,0,1,1,15.43,0Z"/></g></g></svg> 
-  <h1>We&rsquo;ll be back soon!</h1> 
-  <div> 
-    <p>Sorry for the inconvenience.</br>We&rsquo;re performing <b><u>maintenance at the moment.</u></b></br>We&rsquo;ll be back up shortly!</p> 
-  <h1>Wir sind bald wieder da!</h1> 
-  <div> 
-    <p>Bitte entschuldigen Sie die Unannehmlichkeiten.</br>Wir f&uuml;hren <b><u>im Moment Wartungsarbeiten</u></b> durch.</br>Wir sind in K&uuml;rze wieder online!</p> 
-  </div> 
-</article> 
-</code> 
- 
-==== Maintenance-Konfiguration: Neustart ==== 
- 
-Bevor **__weitere__** **Konfigurationsschritte** erfolgen, sollte ein **Neustart** erfolgen, was mit nachfolgendem Befehl durchgeführt werden kann: 
-<code> 
-# systemctl restart haproxy.service 
-</code> 
- 
-:!: **HINWEIS** - **Es erfolgen __keine__ weiteren Ausgaben, wenn der Start erfolgreich war !** 
- 
-==== Maintenance-Konfiguration: Test ==== 
- 
-Wenn der Start des [[https://www.haproxy.org/|HAProxy]] erfolgreich durchgeführt wurde, kann die Abfrage mittels eines //Clients// erfolgen, wie im nachfolgenden Bild dargestellt: 
- 
-{{:tachtler:haproxy:haproxy-archlinux_maintenance.png|HAProxy - Maintenance}} 
- 
- 
- 
-FIXME **Hier geht es weiter... / To be continued ...** 
  
tachtler/haproxy_archlinux.1674318217.txt.gz · Zuletzt geändert: 2023/01/21 17:23 von klaus