<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
	<id>https://wiki.ixheim.de/index.php?action=history&amp;feed=atom&amp;title=Nginx_mit_Modsecurity_Erweitert</id>
	<title>Nginx mit Modsecurity Erweitert - Versionsgeschichte</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.ixheim.de/index.php?action=history&amp;feed=atom&amp;title=Nginx_mit_Modsecurity_Erweitert"/>
	<link rel="alternate" type="text/html" href="https://wiki.ixheim.de/index.php?title=Nginx_mit_Modsecurity_Erweitert&amp;action=history"/>
	<updated>2026-06-29T06:43:58Z</updated>
	<subtitle>Versionsgeschichte dieser Seite in Xinux Wiki</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>https://wiki.ixheim.de/index.php?title=Nginx_mit_Modsecurity_Erweitert&amp;diff=64009&amp;oldid=prev</id>
		<title>Thomas.will: /* NGINX Site-Konfiguration (/etc/nginx/sites-available/default) */</title>
		<link rel="alternate" type="text/html" href="https://wiki.ixheim.de/index.php?title=Nginx_mit_Modsecurity_Erweitert&amp;diff=64009&amp;oldid=prev"/>
		<updated>2025-07-25T15:19:55Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;NGINX Site-Konfiguration (/etc/nginx/sites-available/default)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;de&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Nächstältere Version&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Version vom 25. Juli 2025, 15:19 Uhr&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l53&quot; &gt;Zeile 53:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 53:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     }&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     }&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     location /_waflog {&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     location /_waflog {&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         alias /var/log/nginx/modsec_audit.log;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         alias /var/log/nginx/modsec_audit.log;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;allow 192.168.178.0&lt;/del&gt;/&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;24&lt;/del&gt;;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;types { }&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;deny all&lt;/del&gt;;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;        default_type text&lt;/ins&gt;/&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;plain&lt;/ins&gt;;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;    &lt;/del&gt;}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;auth_basic &amp;quot;ModSecurity Auditlog&amp;quot;;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;        auth_basic_user_file /etc/nginx/.htpasswd&lt;/ins&gt;;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Thomas.will</name></author>
	</entry>
	<entry>
		<id>https://wiki.ixheim.de/index.php?title=Nginx_mit_Modsecurity_Erweitert&amp;diff=64008&amp;oldid=prev</id>
		<title>Thomas.will: Die Seite wurde neu angelegt: „= NGINX + ModSecurity (v3) als Reverse Proxy mit OWASP CRS =  Diese Konfiguration stellt einen TLS-gesicherten Reverse-Proxy mit aktiver ModSecurity-WAF und OW…“</title>
		<link rel="alternate" type="text/html" href="https://wiki.ixheim.de/index.php?title=Nginx_mit_Modsecurity_Erweitert&amp;diff=64008&amp;oldid=prev"/>
		<updated>2025-07-25T15:02:13Z</updated>

		<summary type="html">&lt;p&gt;Die Seite wurde neu angelegt: „= NGINX + ModSecurity (v3) als Reverse Proxy mit OWASP CRS =  Diese Konfiguration stellt einen TLS-gesicherten Reverse-Proxy mit aktiver ModSecurity-WAF und OW…“&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= NGINX + ModSecurity (v3) als Reverse Proxy mit OWASP CRS =&lt;br /&gt;
&lt;br /&gt;
Diese Konfiguration stellt einen TLS-gesicherten Reverse-Proxy mit aktiver ModSecurity-WAF und OWASP CRS bereit. Ziel ist die Absicherung von Backend-Webdiensten, ergänzt durch Logging und optionale Anzeige des Audit-Logs im Browser.&lt;br /&gt;
&lt;br /&gt;
== Struktur ==&lt;br /&gt;
* TLS-Zertifikate aus interner CA (crt.pem, privkey.pem, ca.crt)&lt;br /&gt;
* Reverse Proxy auf Port 443 → Ziel: http://192.168.178.66&lt;br /&gt;
* Weiterleitung von HTTP auf HTTPS&lt;br /&gt;
* Logging ins access.log + modsec_audit.log + modsec_debug.log&lt;br /&gt;
* OWASP Core Rule Set aktiviert&lt;br /&gt;
* Beispielregel zur Erkennung von `&amp;lt;script&amp;gt;` im Query&lt;br /&gt;
&lt;br /&gt;
== NGINX Site-Konfiguration (/etc/nginx/sites-available/default) ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# HTTP → HTTPS Redirect&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
    server_name localhost;&lt;br /&gt;
    return 301 https://$host$request_uri;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
# HTTPS-Server mit TLS-Zertifikat und ModSecurity&lt;br /&gt;
server {&lt;br /&gt;
    listen 443 ssl;&lt;br /&gt;
    server_name localhost;&lt;br /&gt;
&lt;br /&gt;
    ssl_certificate     /etc/nginx/crt.pem;&lt;br /&gt;
    ssl_certificate_key /etc/nginx/privkey.pem;&lt;br /&gt;
    ssl_client_certificate /etc/nginx/ca.crt;&lt;br /&gt;
&lt;br /&gt;
    ssl_protocols TLSv1.2 TLSv1.3;&lt;br /&gt;
    ssl_prefer_server_ciphers on;&lt;br /&gt;
    ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384';&lt;br /&gt;
&lt;br /&gt;
    access_log /var/log/nginx/access.log waf_combined;&lt;br /&gt;
    error_log  /var/log/nginx/error.log warn;&lt;br /&gt;
&lt;br /&gt;
    add_header Strict-Transport-Security &amp;quot;max-age=31536000; includeSubDomains&amp;quot; always;&lt;br /&gt;
    add_header Cache-Control &amp;quot;no-store, no-cache, must-revalidate&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
    error_page 403 /403.html;&lt;br /&gt;
    location = /403.html {&lt;br /&gt;
        root /var/www/html;&lt;br /&gt;
        internal;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    include /etc/nginx/modsec/main.conf;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://192.168.178.66;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_set_header X-Real-IP $remote_addr;&lt;br /&gt;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    location /_waflog {&lt;br /&gt;
        alias /var/log/nginx/modsec_audit.log;&lt;br /&gt;
        allow 192.168.178.0/24;&lt;br /&gt;
        deny all;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ModSecurity-Konfiguration (/etc/nginx/modsec/modsecurity.conf) ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
SecRuleEngine On&lt;br /&gt;
SecRequestBodyAccess On&lt;br /&gt;
SecResponseBodyAccess Off&lt;br /&gt;
&lt;br /&gt;
SecAuditEngine RelevantOnly&lt;br /&gt;
SecAuditLog /var/log/nginx/modsec_audit.log&lt;br /&gt;
SecAuditLogParts ABIJDEFHZ&lt;br /&gt;
&lt;br /&gt;
SecDebugLog /var/log/nginx/modsec_debug.log&lt;br /&gt;
SecDebugLogLevel 3&lt;br /&gt;
&lt;br /&gt;
SecTmpDir /tmp/&lt;br /&gt;
SecDataDir /tmp/&lt;br /&gt;
&lt;br /&gt;
SecRule ARGS &amp;quot;@contains script&amp;quot; \&lt;br /&gt;
    &amp;quot;id:9999,phase:1,deny,log,status:403,msg:'Test rule triggered'&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Include /etc/nginx/modsec/coreruleset/crs-setup.conf&lt;br /&gt;
Include /etc/nginx/modsec/coreruleset/rules/*.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Erweitertes Logging (in nginx.conf einfügen) ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
log_format waf_combined '$remote_addr - $remote_user [$time_local] '&lt;br /&gt;
                        '&amp;quot;$request&amp;quot; $status $body_bytes_sent '&lt;br /&gt;
                        '&amp;quot;$http_referer&amp;quot; &amp;quot;$http_user_agent&amp;quot; '&lt;br /&gt;
                        'ModSecID=$request_id Host=&amp;quot;$host&amp;quot; URI=&amp;quot;$request_uri&amp;quot;';&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Rechte und Dateianlage für Logs ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
touch /var/log/nginx/modsec_audit.log /var/log/nginx/modsec_debug.log&lt;br /&gt;
chown www-data:www-data /var/log/nginx/modsec_*.log&lt;br /&gt;
chmod 640 /var/log/nginx/modsec_*.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Aktivierung ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ln -sf /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default&lt;br /&gt;
nginx -t &amp;amp;&amp;amp; systemctl reload nginx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Hinweise ==&lt;br /&gt;
* Die Audit-Log-Datei kann über `/waflog` im Browser angezeigt werden (intern erlaubt).&lt;br /&gt;
* Der `crs-setup.conf` definiert Schwellenwerte, Paranoia-Level und Variablenkontrolle.&lt;br /&gt;
* Die Regeln befinden sich unter: `/etc/nginx/modsec/coreruleset/rules/`&lt;br /&gt;
* ModSecurity greift nur, wenn `include /etc/nginx/modsec/main.conf` gesetzt ist.&lt;br /&gt;
&lt;br /&gt;
[[KATEGORIE:WAF]]&lt;/div&gt;</summary>
		<author><name>Thomas.will</name></author>
	</entry>
</feed>