Nginx Proxy vor checkmk Rocky

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen

Install nginx

nginx dient als Reverse Proxy mit TLS vor der Checkmk-Site.

  • dnf install nginx

Site-Apache auf Loopback-Port

Der site-eigene Apache wird vom Socket auf einen festen TCP-Port am Loopback umgestellt, damit nginx ihn als Backend erreichen kann.

  • omd stop kitlab
  • omd config kitlab set APACHE_TCP_ADDR 127.0.0.1
  • omd config kitlab set APACHE_TCP_PORT 5000
  • omd start kitlab

System-Apache aus

httpd wurde als Abhängigkeit des Checkmk-RPM mitinstalliert und wird nicht benötigt – deaktivieren, nicht deinstallieren.

  • systemctl disable --now httpd

SELinux

Der Boolean erlaubt nginx (Domain httpd_t) ausgehende Netzwerkverbindungen zum Site-Apache auf 127.0.0.1:5000.

  • setsebool -P httpd_can_network_connect 1

nginx vhost

nginx terminiert TLS mit dem Lab-Zertifikat, leitet HTTP auf HTTPS um und reicht Anfragen an den Site-Apache weiter.

  • /etc/nginx/conf.d/checkmk.conf

server {

   listen 80;
   server_name checkmk.it213.int;
   return 301 https://$host$request_uri;

}

server {

   listen 443 ssl;
   http2 on;
   server_name checkmk.it213.int;
   ssl_certificate     /etc/nginx/own.crt;
   ssl_certificate_key /etc/nginx/own.key;
   ssl_protocols       TLSv1.2 TLSv1.3;
   location /kitlab/ {
       proxy_pass http://127.0.0.1:5000/kitlab/;
       proxy_set_header Host $host;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto https;
   }

}

Achtung
Ohne X-Forwarded-Proto https → Redirect-Schleife nach dem Login

Firewall

HTTPS wird in der Default-Zone dauerhaft freigegeben.

  • firewall-cmd --permanent --add-service=https
  • firewall-cmd --reload

Test & Start

Konfiguration prüfen, dann nginx aktivieren und starten.

  • nginx -t
  • systemctl enable --now nginx

Url

Die Web-UI ist jetzt nur noch per HTTPS erreichbar.