<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Brandon Fong</title>
    <description>The latest articles on Forem by Brandon Fong (@brandonmfong).</description>
    <link>https://forem.com/brandonmfong</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2514238%2F61e2cd4a-d01a-46d9-80ef-ab35e1484673.jpeg</url>
      <title>Forem: Brandon Fong</title>
      <link>https://forem.com/brandonmfong</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/brandonmfong"/>
    <language>en</language>
    <item>
      <title>Running Nextcloud on TrueNAS behind Nginx Reverse Proxy</title>
      <dc:creator>Brandon Fong</dc:creator>
      <pubDate>Sat, 14 Dec 2024 18:29:27 +0000</pubDate>
      <link>https://forem.com/brandonmfong/running-nextcloud-on-truenas-behind-nginx-reverse-proxy-10ik</link>
      <guid>https://forem.com/brandonmfong/running-nextcloud-on-truenas-behind-nginx-reverse-proxy-10ik</guid>
      <description>&lt;p&gt;How I got mine to work with Nextcloud running on TrueNAS using a Rpi 3 my DNS provider &amp;amp; Nginx Proxy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cloudflare
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Create an &lt;code&gt;A&lt;/code&gt; record pointing domain to private address of your Nginx Proxy Manager: &lt;code&gt;npm.example.com&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Create a &lt;code&gt;CNAME&lt;/code&gt; record for all subdomains: &lt;code&gt;*.example.com&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Pi-hole (&lt;strong&gt;Docker Tag&lt;/strong&gt; &lt;a href="https://github.com/pi-hole/docker-pi-hole/releases/2024.07.0" rel="noopener noreferrer"&gt;2024.07.0&lt;/a&gt; &lt;strong&gt;Pi-hole&lt;/strong&gt; &lt;a href="https://github.com/pi-hole/pi-hole/releases/v5.18.3" rel="noopener noreferrer"&gt;v5.18.3&lt;/a&gt; &lt;strong&gt;FTL&lt;/strong&gt; &lt;a href="https://github.com/pi-hole/FTL/releases/v5.25.2" rel="noopener noreferrer"&gt;v5.25.2&lt;/a&gt; &lt;strong&gt;Web Interface&lt;/strong&gt; &lt;a href="https://github.com/pi-hole/AdminLTE/releases/v5.21" rel="noopener noreferrer"&gt;v5.21&lt;/a&gt;) configuration
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Add DNS record pointing to the Nginx Proxy Manager host: &lt;code&gt;npm.example.com -&amp;gt; 192.168.x.x&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Add a CNAME record: &lt;code&gt;nc.example.com -&amp;gt; npm.example.com&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  TrueNAS (ElectricEel-24.10.0.2) Config
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;clear the &lt;code&gt;Host&lt;/code&gt; name field&lt;/li&gt;
&lt;li&gt;Use the &lt;code&gt;truenas_default&lt;/code&gt; certificate&lt;/li&gt;
&lt;li&gt;No additional environment variables&lt;/li&gt;
&lt;li&gt;Uncheck &lt;code&gt;Use different port for URL rewrites&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Port &lt;code&gt;9001&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Nginx Proxy Manager (v2.12.1)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Proxy Host entry:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Domain Names: &lt;code&gt;nc.example.com&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Scheme: &lt;code&gt;https&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Forward Hostname / IP: &lt;code&gt;Truenas' private ip on my network&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Port: &lt;code&gt;9001&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Custom Nginx Config:
&lt;/li&gt;
&lt;/ul&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  client_body_buffer_size 512k;
  proxy_read_timeout 86400s;
  client_max_body_size 0;
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;SSL Certificate creation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Follow &lt;strong&gt;Step 2&lt;/strong&gt; from &lt;a href="https://www.wundertech.net/local-ssl-for-home-lab-services-nginx-proxy-manager/" rel="noopener noreferrer"&gt;this tutorial&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Nextcloud &lt;code&gt;config.php&lt;/code&gt; modifications
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;'overwrite.cli.url' =&amp;gt; 'https://nc.example.com'&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;'overwritehost' =&amp;gt; 'nc.example.com'&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;'overwriteprotocol' =&amp;gt; 'https'&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Add &lt;code&gt;nc.example.com&lt;/code&gt; to &lt;code&gt;trusted_domains&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Add Pihole's ip address to &lt;code&gt;trusted_proxies&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;I'd also back this file up as I don't know what will happen to it during an update through TrueNAS&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>nextcloud</category>
      <category>truenas</category>
      <category>nginx</category>
    </item>
    <item>
      <title>Range-Based For Loop Implementation</title>
      <dc:creator>Brandon Fong</dc:creator>
      <pubDate>Tue, 10 Dec 2024 17:47:21 +0000</pubDate>
      <link>https://forem.com/brandonmfong/range-based-for-loop-implementation-4o8a</link>
      <guid>https://forem.com/brandonmfong/range-based-for-loop-implementation-4o8a</guid>
      <description>&lt;p&gt;I was interested in learning how to make my &lt;a href="https://github.com/BrandonMFong/libs/blob/dev/bflibcpp/src/list.hpp" rel="noopener noreferrer"&gt;Linked List class&lt;/a&gt; adhere to a range-based for loop. I eventually saw a really good &lt;a href="https://github.com/BrandonMFong/libs/blob/dev/bflibcpp/src/list.hpp" rel="noopener noreferrer"&gt;stackoverflow response&lt;/a&gt; that helped me figure out how to do it. This is my attempt at showing you how I implemented this feature with minimal lines of code. I will be speaking in context of a Linked List class.&lt;/p&gt;

&lt;p&gt;Recall this is what the CPP documentation says about the &lt;a href="https://en.cppreference.com/w/cpp/language/range-for" rel="noopener noreferrer"&gt;Range-Based For Loop&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
for ( range-declaration : range-expression )

loop-statement 

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;range-declaration = the variable you are going to use to hold onto the node object&lt;/li&gt;
&lt;li&gt;range-expression = the Linked List class&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What you need for your Linked List class are two things:&lt;/p&gt;

&lt;p&gt;Two methods:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Iterator begin() { return this-&amp;gt;first(); }
Iterator end() { return NULL; }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;begin() returns the first node of your Linked List (note first() returns a class Node) and end() will return NULL to identify the end of the list.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;An Iterator class&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Notice both methods return Iterator. This is a nested class inside the Linked List:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Iterator {
private:
    Node * _curr;
public:
    Iterator(Node * n) : _curr(n) {}
    L operator*() const { 
        return this-&amp;gt;_curr-&amp;gt;object();
    }
    Iterator &amp;amp; operator++() { // pre-inc
        this-&amp;gt;_curr = this-&amp;gt;_curr-&amp;gt;next();
        return *this;
    }
    Iterator operator++(int) { // post-inc
        Iterator old = *this;
        this-&amp;gt;operator++();
        return old;
    }
    bool operator!=(const Iterator&amp;amp; i) {
        return !(*this == i);
    }
    bool operator==(const Iterator&amp;amp; i) {
        return this-&amp;gt;_curr == i._curr;
    }
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What I needed in this class, respectfully, was: a constructor that allows me return a Node coming from my Linked Lists’s begin(); then overloaders for the iteration, comparisons, and casting. Nest this class inside of the LinkedList class.&lt;/p&gt;

&lt;p&gt;Simple and it did the job. What I needed was an iterator class that handles the iterative requirements for the range-based for loop. I also need to provide two accessor methods in my LinkedList class so the for loop can use it. You can see a demonstration of using my LinkedList class &lt;a href="https://github.com/BrandonMFong/libs/blob/dev/bflibcpp/testbench/list_tests.hpp#L622" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>datastructures</category>
      <category>l</category>
    </item>
  </channel>
</rss>
