<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>dynamic modules &#8211; matthias.guru</title>
	<atom:link href="https://matthias.guru/tag/dynamic-modules/feed/" rel="self" type="application/rss+xml" />
	<link>https://matthias.guru</link>
	<description>Tipps und Tricks rund um Serveradministration, Werbeeinnahmen und allem was mit meiner IT Selbstständigkeit zu tun hat</description>
	<lastBuildDate>Mon, 11 Feb 2019 13:51:40 +0000</lastBuildDate>
	<language>de-DE</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.0.3</generator>
	<item>
		<title>nginx dynamic modules kompilieren und nutzen</title>
		<link>https://matthias.guru/2019/02/11/nginx-dynamic-modules-kompilieren-und-nutzen/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=nginx-dynamic-modules-kompilieren-und-nutzen</link>
					<comments>https://matthias.guru/2019/02/11/nginx-dynamic-modules-kompilieren-und-nutzen/#comments</comments>
		
		<dc:creator><![CDATA[Matthias]]></dc:creator>
		<pubDate>Mon, 11 Feb 2019 13:51:40 +0000</pubDate>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[dynamic modules]]></category>
		<category><![CDATA[nginx]]></category>
		<guid isPermaLink="false">https://matthiasdietel.de/?p=312</guid>

					<description><![CDATA[Wenn man nginx um ein Modul erweitern will, aber nicht das gesamte nginx neu kompilieren möchte oder kann, z.b. weil man fertige Pakete aus einer Paketquelle installiert hat, kann man das gewünschte Modul dynamisch nachträglich <a class="mh-excerpt-more" href="https://matthias.guru/2019/02/11/nginx-dynamic-modules-kompilieren-und-nutzen/" title="nginx dynamic modules kompilieren und nutzen">[...]</a>]]></description>
										<content:encoded><![CDATA[
<p>Wenn man nginx um ein Modul erweitern will, aber nicht das gesamte nginx neu kompilieren möchte oder kann, z.b. weil man fertige Pakete aus einer Paketquelle installiert hat, kann man das gewünschte Modul dynamisch nachträglich einbinden.</p>



<p>Das ganze ist eigentlich recht einfach. Wir benötigen den Quellcode unserer gerade installierten nginx Version, sowie den Quellcode des gewünschten Moduls. Dann bauen wir beides zusammen, nehmen aber nur das erstelle Modul und binden es in die vorhandene nginx Installation ein. Wie so immer müssen wir jedoch auf das ein oder andere Detail achten.</p>



<p>Wir brauchen den Quellcode der nginx Version die wir bereits installiert haben. Diese bekomen wir mit folgendem Befehl:</p>



<pre class="wp-block-preformatted">nginx -v</pre>



<p>Das Ergbnis sieht so aus: </p>



<figure class="wp-block-image"><img width="224" height="20" src="https://matthias.guru/wp-content/uploads/2019/02/grafik-4.png" alt="" class="wp-image-313"/></figure>



<p>Jetzt wissen wir also dass wir aktuell Version 1.15.8 installiert haben und können uns davon den Quellcode herunterladen:</p>



<pre class="wp-block-preformatted">wget http://nginx.org/download/nginx-1.15.8.tar.gz <br>tar -xzvf nginx-1.15.8.tar.gz</pre>



<p>Nun benötigen wir den Quellcode des gewünschten Moduls. Als Beispiel nehme ich hier das NAXSI Modul:</p>



<pre class="wp-block-preformatted">git clone https://github.com/nbs-system/naxsi.git</pre>



<p>Jetzt wechseln wir in den nginx Ordner</p>



<p>cd nginx-1.15.8</p>



<p>Bevor wir nun aber nginx und das Modul bauen können, benötigen wir noch die Build Flags des bereits installierten nginx, sonst bekommen wir später folgende Meldung:</p>



<pre class="wp-block-code"><code>dynamic module is not binary compatible with nginx</code></pre>



<p>Um die Flags festzustellen nutzen wir den Befehl</p>



<pre class="wp-block-preformatted">nginx -V</pre>



<p>Was uns die gesuchten Flags anzeigt</p>



<figure class="wp-block-image"><img loading="lazy" width="654" height="383" src="https://matthias.guru/wp-content/uploads/2019/02/grafik-5.png" alt="" class="wp-image-314" srcset="https://matthias.guru/wp-content/uploads/2019/02/grafik-5.png 654w, https://matthias.guru/wp-content/uploads/2019/02/grafik-5-300x176.png 300w" sizes="(max-width: 654px) 100vw, 654px" /></figure>



<p>Der nun zu verwendente Buildbefehl sieht so aus und muss durch die gerade festgestellten Flags erweitert werden:</p>



<pre class="wp-block-code"><code>./configure --with-compat --add-dynamic-module=../naxsi/naxsi_src</code></pre>



<p>Was dann bei mir so aussieht:</p>



<pre class="wp-block-preformatted">./configure --with-compat --add-dynamic-module=../naxsi/naxsi_src  <br>
--prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -fdebug-prefix-map=/data/builder/debuild/nginx-1.15.8/debian/debuild-base/nginx-1.15.8=. -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-specs=/usr/share/dpkg/no-pie-link.specs -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie'</pre>



<p>Nachdem der Befehl erfolgreich abgeschlossen wurde, erstellen wir noch die Module mit</p>



<pre class="wp-block-preformatted">make modules</pre>



<p>Nun ist das Modul bereit zu Verwendung. Dazu kopieren wir es in den nginx modules Ordner</p>



<pre class="wp-block-preformatted">cp objs/ngx_http_naxsi_module.so /etc/nginx/modules</pre>



<p>Und aktivieren es in der nginx.conf</p>



<pre class="wp-block-preformatted">load_module modules/ngx_http_naxsi_module.so;</pre>



<p>Das war es auch schon. Nginx abschließend neustarten und das Modul wird geladen.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://matthias.guru/2019/02/11/nginx-dynamic-modules-kompilieren-und-nutzen/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
