<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Peek Read Info (Posts about nginx)</title><link>https://peekread.info/</link><description></description><atom:link href="https://peekread.info/tags/nginx.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Contents © 2024 &lt;a href="mailto:dugite-code@peekread.info"&gt;Dugite-Code&lt;/a&gt; 
&lt;a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/"&gt;
&lt;img alt="Creative Commons License BY-SA"
width="88px" height="31px" style="border-width:0; margin-bottom:12px;"
src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png"&gt;&lt;/a&gt;</copyright><lastBuildDate>Wed, 14 Feb 2024 06:33:09 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Readable Nginx configs</title><link>https://peekread.info/tech/20220907-readable-nginx-configs/</link><dc:creator>Dugite-Code</dc:creator><description>&lt;p&gt;&lt;/p&gt;&lt;div class="d-flex position-relative pt-3 pb-3"&gt;
    &lt;div class="flex-shrink-0 me-3"&gt;
        &lt;img data-pagefind-meta="image[src], image_alt[alt]" style="height:89px;" src="https://peekread.info/images/2019/0625-server-set-up-checklist/image01.png" alt="Configure your linux server"&gt;
    &lt;/div&gt;
    &lt;div&gt;
        &lt;p class="mt-3"&gt;&lt;/p&gt;&lt;p&gt;A recent project announcement on the subredit &lt;a href="https://www.reddit.com/r/selfhosted/comments/x7gpwd/making_nginx_easier_to_use_like_caddy/"&gt;/r/selfhosted&lt;/a&gt; reminded me to post about a simple trick I've started using to make the configuration of the webserver Nginx a little more ergonomic.&lt;/p&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Nginx allows you to include files inline in your configs to make re-using code simple. An example would be all your ssl proxy settings as per generated using the &lt;a href="https://ssl-config.mozilla.org/#server=nginx&amp;amp;version=1.17.7&amp;amp;config=modern&amp;amp;openssl=1.1.1k&amp;amp;guideline=5.6"&gt;Mozilla ssl-config&lt;/a&gt; generator.&lt;/p&gt;
&lt;p&gt;simply add this config to a file like &lt;code&gt;/etc/nginx/include.d/include.ssl_sec&lt;/code&gt; with your cert paths modified and include it in your config:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;upstream&lt;span class="w"&gt; &lt;/span&gt;example_service&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;server&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;127&lt;/span&gt;.0.0.1:8080&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;keepalive&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;32&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

server&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;server_name&lt;span class="w"&gt; &lt;/span&gt;example.tld&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;#Mozilla modern tls config&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;include&lt;span class="w"&gt; &lt;/span&gt;/etc/nginx/include.d/include.ssl_sec&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="w"&gt;  &lt;/span&gt;location&lt;span class="w"&gt; &lt;/span&gt;/&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;#Common Proxy settings&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;include&lt;span class="w"&gt; &lt;/span&gt;/etc/nginx/include.d/include.proxy_settings&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;proxy_pass&lt;span class="w"&gt; &lt;/span&gt;http://example_service/&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Now you have a nice easy config file that can be easily used as a template for new services. Adding additional configurations to files really makes it quick and easy to deploy new services without needing complicated projects like Nginx Proxy Manager&lt;/p&gt;</description><category>nginx</category><category>quick post</category><guid>https://peekread.info/tech/20220907-readable-nginx-configs/</guid><pubDate>Tue, 06 Sep 2022 16:00:00 GMT</pubDate></item></channel></rss>