<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Domain on balharrie.uk</title>
        <link>https://balharrie.uk/tags/domain/</link>
        <description>Recent content in Domain on balharrie.uk</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>en</language>
        <lastBuildDate>Mon, 01 Aug 2022 00:00:00 +0000</lastBuildDate><atom:link href="https://balharrie.uk/tags/domain/index.xml" rel="self" type="application/rss+xml" /><item>
        <title>Using my domain for self hosted services</title>
        <link>https://balharrie.uk/p/using-my-domain-for-self-hosted-services/</link>
        <pubDate>Mon, 01 Aug 2022 00:00:00 +0000</pubDate>
        
        <guid>https://balharrie.uk/p/using-my-domain-for-self-hosted-services/</guid>
        <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; After publishing this post, I later realised that whilst using the &amp;ldquo;Filters&amp;rdquo; in AdGuard home worked, it was not the right solution and DNS rewrites was actually the better option - I used &amp;ldquo;Filters&amp;rdquo; as I intially ran into a bug with AdGuard Home that was later fixed.  Don&amp;rsquo;t do as I did!&lt;/p&gt;&lt;/blockquote&gt;
&lt;h2 id=&#34;overview&#34;&gt;Overview&lt;/h2&gt;
&lt;p&gt;Back when I bought my second Ubiquiti product, &lt;a class=&#34;link&#34; href=&#34;https://store.ui.com/products/unifi-security-gateway&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;(the UniFi Security Gateway, or USG 3)&lt;/a&gt; I started utilising the built in VPN server.  Since then I&amp;rsquo;ve moved to the Dream Machine Pro and tested out TailScale, but I still keep coming back to this rock solid VPN server.&lt;/p&gt;
&lt;p&gt;Since this worked so well, I made the decision not to open up any of my self-hosted services to be directly internet facing.  I really wanted easy to understand sub-domains for my self hosted services, so I didn&amp;rsquo;t have to go about remembering what host IP and port things ran on or try to explain that to family members!&lt;/p&gt;
&lt;p&gt;I landed on a solution I came up with using NGINX Proxy Manager, Adguard Home and LetsEncrypt.  It isn&amp;rsquo;t the most elegant, and I&amp;rsquo;m sure many people would be able to point out flaws or ways it could be improved, but it works.&lt;/p&gt;
&lt;h2 id=&#34;diagram&#34;&gt;Diagram&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://balharrie.uk/p/using-my-domain-for-self-hosted-services/001.png&#34;
	width=&#34;1920&#34;
	height=&#34;256&#34;
	srcset=&#34;https://balharrie.uk/p/using-my-domain-for-self-hosted-services/001_hu_7173066f989ac1b0.png 480w, https://balharrie.uk/p/using-my-domain-for-self-hosted-services/001_hu_47cec304775e9c7c.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;Traffic flow diagram&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;750&#34;
		data-flex-basis=&#34;1800px&#34;
	
&gt;&lt;/p&gt;
&lt;h2 id=&#34;so-whats-happening-here&#34;&gt;So what&amp;rsquo;s happening here?&lt;/h2&gt;
&lt;p&gt;Say your domain is &lt;code&gt;mydomain.com&lt;/code&gt;.  Let&amp;rsquo;s say you setup &lt;a class=&#34;link&#34; href=&#34;https://nextcloud.com&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;NextCloud&lt;/a&gt; and you want it&amp;rsquo;s web UI to be available at &lt;code&gt;nextcloud.mydomain.com&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;With this setup, when you access &lt;code&gt;nextcloud.mydomain.com&lt;/code&gt; on your device, it will check for the DNS entry with your AdGuard Home instance.  Since AdGuard has a record for it, traffic is passed to Nginx Proxy Manager.&lt;/p&gt;
&lt;p&gt;Nginx Proxy Manager has an entry for the sub-domain, which uses a (*wildcard) SSL certificate created through Let&amp;rsquo;s Encrypt.  Traffic is then directed to the IP address and port of the self-hosted app you have setup.&lt;/p&gt;
&lt;h2 id=&#34;replicating-this-setup&#34;&gt;Replicating this setup&lt;/h2&gt;
&lt;p&gt;You will need:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A domain name i.e. &lt;em&gt;yourname.com&lt;/em&gt; or similar&lt;/li&gt;
&lt;li&gt;A machine to run AdGuard Home and NGINX Proxy Manager (a Raspberry Pi is more than capable!)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;adguard-home&#34;&gt;AdGuard Home&lt;/h2&gt;
&lt;h3 id=&#34;installing&#34;&gt;Installing&lt;/h3&gt;
&lt;p&gt;I currently have my AdGuard instance installed as a &lt;a class=&#34;link&#34; href=&#34;https://community.home-assistant.io/t/home-assistant-community-add-on-adguard-home/90684&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Home-Assistant add-on&lt;/a&gt;.  You could also install it as a &lt;a class=&#34;link&#34; href=&#34;https://hub.docker.com/r/adguard/adguardhome&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Docker container&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;point-your-dns-to-adguard-home&#34;&gt;Point your DNS to AdGuard Home&lt;/h3&gt;
&lt;p&gt;Now that you have AdGuard up and running, make sure you point your DNS requests to it.  You can do this on a client-by-client basis by changing your network settings, or you should be able to do this for your whole network in your router settings (probably under something related to DHCP?)&lt;/p&gt;
&lt;h3 id=&#34;setting-up-custom-filtering&#34;&gt;Setting up custom filtering&lt;/h3&gt;
&lt;p&gt;Once it&amp;rsquo;s up and running, open up the AdGuard Home interface and click on &amp;ldquo;Filters&amp;rdquo; then &amp;ldquo;Custom filtering rules&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://balharrie.uk/p/using-my-domain-for-self-hosted-services/002.png&#34;
	width=&#34;1072&#34;
	height=&#34;480&#34;
	srcset=&#34;https://balharrie.uk/p/using-my-domain-for-self-hosted-services/002_hu_3a3e42c5ee6f1c01.png 480w, https://balharrie.uk/p/using-my-domain-for-self-hosted-services/002_hu_6a433afc195a1c33.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;AdGuard Home filters menu&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;223&#34;
		data-flex-basis=&#34;536px&#34;
	
&gt;&lt;/p&gt;
&lt;p&gt;Once here you will need to make an entry for every sub-domain, with the IP address of your Nginx Proxy Manager box first.  e.g:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://balharrie.uk/p/using-my-domain-for-self-hosted-services/003.png&#34;
	width=&#34;1110&#34;
	height=&#34;432&#34;
	srcset=&#34;https://balharrie.uk/p/using-my-domain-for-self-hosted-services/003_hu_aa422f6f4aec4cc9.png 480w, https://balharrie.uk/p/using-my-domain-for-self-hosted-services/003_hu_ef7af035df32b28c.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;AdGuard custom filtering rules&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;256&#34;
		data-flex-basis=&#34;616px&#34;
	
&gt;&lt;/p&gt;
&lt;h2 id=&#34;ngninx-proxy-manager&#34;&gt;Ngninx Proxy Manager&lt;/h2&gt;
&lt;h3 id=&#34;installing-1&#34;&gt;Installing&lt;/h3&gt;
&lt;p&gt;I have Nginx Proxy Manager installed as a &lt;a class=&#34;link&#34; href=&#34;https://community.home-assistant.io/t/home-assistant-community-add-on-nginx-proxy-manager/111830&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Home-Assistant add-on&lt;/a&gt;.  You could also install it as a &lt;a class=&#34;link&#34; href=&#34;https://hub.docker.com/r/jc21/nginx-proxy-manager&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Docker container&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&#34;setting-up-a-proxy-host&#34;&gt;Setting up a Proxy Host&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;From the dashboard, click &amp;ldquo;Hosts&amp;rdquo; then &amp;ldquo;Proxy Hosts&amp;rdquo;.&lt;/li&gt;
&lt;li&gt;Click &amp;ldquo;Add Proxy Host&amp;rdquo;&lt;/li&gt;
&lt;/ul&gt;
</description>
        </item>
        
    </channel>
</rss>
