<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by abhiraj singh tomar on Medium]]></title>
        <description><![CDATA[Stories by abhiraj singh tomar on Medium]]></description>
        <link>https://medium.com/@abhirajsinghtomar?source=rss-9bcf1f03e405------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*fyREewY7L7QAWxpZ.jpg</url>
            <title>Stories by abhiraj singh tomar on Medium</title>
            <link>https://medium.com/@abhirajsinghtomar?source=rss-9bcf1f03e405------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 10:19:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abhirajsinghtomar/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Hosting Private Apps on Your Own Domain with Tailscale and Caddy]]></title>
            <link>https://medium.com/@abhirajsinghtomar/hosting-private-apps-on-your-own-domain-with-tailscale-and-caddy-1b1c57bccaff?source=rss-9bcf1f03e405------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b1c57bccaff</guid>
            <category><![CDATA[tailscale]]></category>
            <category><![CDATA[caddy]]></category>
            <category><![CDATA[caddy-server]]></category>
            <category><![CDATA[vpn]]></category>
            <category><![CDATA[self-hosting]]></category>
            <dc:creator><![CDATA[abhiraj singh tomar]]></dc:creator>
            <pubDate>Thu, 08 Oct 2026 20:20:14 GMT</pubDate>
            <atom:updated>2026-10-08T20:20:14.252Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FOMMiUwaX6DEwrOi8Gr5Cw.png" /></figure><p>Running applications on a home server or private machine is easy. Giving them clean URLs like:</p><pre>https://dashboard.internal.example.com<br>https://grafana.internal.example.com<br>https://notes.internal.example.com</pre><p>while keeping them completely off the public Internet is slightly more interesting.</p><p>A common setup is:</p><ul><li>a private network such as Tailscale</li><li>a personal domain managed by a DNS provider</li><li>a reverse proxy such as Caddy</li><li>an internal DNS server such as dnsmasq</li><li>publicly trusted TLS certificates obtained through DNS validation</li></ul><p>The important part is understanding that these components solve different problems.</p><p>This article builds the architecture from first principles and then walks through a working example.</p><h3>The problem</h3><p>Suppose you have an application running on a private server:</p><pre>http://127.0.0.1:4000</pre><p>The server is reachable over Tailscale at:</p><pre>100.100.50.20</pre><p>You could access the application directly:</p><pre>http://100.100.50.20:4000</pre><p>That works, but it has several disadvantages:</p><ul><li>IP addresses are difficult to remember.</li><li>Ports leak implementation details.</li><li>HTTPS is harder to manage.</li><li>Some browser APIs require a secure HTTPS origin.</li><li>Moving an application to another port requires changing bookmarks and clients.</li><li>Hosting several applications becomes messy.</li></ul><p>Instead, we want:</p><pre>https://app.internal.example.com</pre><p>with the following properties:</p><ol><li>The hostname resolves only for devices on the private network.</li><li>The service is not reachable from the public Internet.</li><li>HTTPS uses a normal browser-trusted certificate.</li><li>Multiple applications can share the same server.</li><li>Internal application ports stay hidden behind a reverse proxy.</li></ol><p>The resulting architecture looks like this:</p><pre>Private application traffic</pre><pre>Laptop / Phone<br>      |<br>      | private network<br>      v<br>app.internal.example.com<br>      |<br>      | private DNS resolves to<br>      v<br>100.100.50.20<br>      |<br>      | HTTPS :443<br>      v<br>    Caddy<br>      |<br>      | reverse proxy<br>      v<br>127.0.0.1:4000</pre><p>There is one additional path used only for obtaining TLS certificates:</p><pre>Caddy<br>  |<br>  | DNS provider API<br>  v<br>Public DNS provider<br>  |<br>  | temporary DNS TXT record<br>  v<br>Certificate Authority</pre><p>These two paths are independent.</p><h3>The four networking problems we need to solve</h3><p>It helps to treat the system as four separate layers.</p><h3>1. Connectivity</h3><p>Can the client reach the server at all?</p><p>Tailscale solves this.</p><p>A private server may receive an address such as:</p><pre>100.100.50.20</pre><p>Devices in the same tailnet can communicate with that address without exposing the machine directly to the Internet.</p><p>Conceptually:</p><pre>Laptop<br>   |<br>   | encrypted overlay network<br>   v<br>Server<br>100.100.50.20</pre><p>This layer has nothing to do with DNS or HTTPS.</p><p>It simply gives devices private network connectivity.</p><h3>2. Name resolution</h3><p>Humans do not want to type:</p><pre>100.100.50.20</pre><p>We want:</p><pre>app.internal.example.com</pre><p>DNS solves this.</p><p>However, we usually do <strong>not</strong> want:</p><pre>app.internal.example.com -&gt; 100.100.50.20</pre><p>published globally in public DNS.</p><p>Instead, we can use <strong>split DNS</strong>.</p><p>Split DNS means different DNS resolvers answer different namespaces.</p><p>For example:</p><pre>google.com<br>    -&gt; public DNS</pre><pre>github.com<br>    -&gt; public DNS</pre><pre>*.internal.example.com<br>    -&gt; private DNS server</pre><p>Tailscale supports configuring specific DNS servers for specific domains.</p><p>We might tell Tailscale:</p><pre>internal.example.com<br>        |<br>        v<br>DNS server 100.100.50.20</pre><p>A lightweight DNS server such as dnsmasq can then answer:</p><pre>app.internal.example.com       -&gt; 100.100.50.20<br>grafana.internal.example.com   -&gt; 100.100.50.20<br>notes.internal.example.com     -&gt; 100.100.50.20</pre><p>An even simpler rule is:</p><pre>*.internal.example.com -&gt; 100.100.50.20</pre><p>Now every internal service points to the reverse proxy.</p><h3>Why a reverse proxy is useful</h3><p>Without a reverse proxy you might expose applications like this:</p><pre>http://server:3000<br>http://server:4000<br>http://server:8080<br>http://server:9090</pre><p>With Caddy:</p><pre>https://grafana.internal.example.com<br>        -&gt; localhost:3000</pre><pre>https://notes.internal.example.com<br>        -&gt; localhost:4000</pre><pre>https://metrics.internal.example.com<br>        -&gt; localhost:9090</pre><p>The client only sees HTTPS on port 443.</p><p>Caddy decides which backend receives the request based on the hostname.</p><p>For example:</p><pre>grafana.internal.example.com {<br>    reverse_proxy 127.0.0.1:3000<br>}</pre><pre>notes.internal.example.com {<br>    reverse_proxy 127.0.0.1:4000<br>}</pre><p>The architecture becomes:</p><pre>Caddy<br>                      |<br>        +-------------+-------------+<br>        |             |             |<br>        v             v             v<br>     Grafana        Notes        Metrics<br>      :3000          :4000         :9090</pre><p>This is the same general architecture commonly used for public websites, except the network itself remains private.</p><h3>Why HTTPS is still necessary on a private network</h3><p>A common misconception is:</p><blockquote><em>Tailscale already encrypts the traffic, so HTTPS is unnecessary.</em></blockquote><p>At the transport level, Tailscale does encrypt traffic.</p><p>But browsers have a separate concept called a <strong>secure context</strong>.</p><p>Many APIs only work when the browser sees:</p><pre>https://...</pre><p>Examples include features such as:</p><ul><li>WebAuthn and passkeys</li><li>service workers</li><li>some credential APIs</li><li>certain clipboard APIs</li><li>some browser security features</li></ul><p>From the browser’s perspective:</p><pre>http://app.internal.example.com</pre><p>is still HTTP.</p><p>The fact that HTTP happens to travel inside an encrypted Tailscale tunnel does not automatically make it an HTTPS origin.</p><p>So we want:</p><pre>https://app.internal.example.com</pre><p>even though the underlying network is private.</p><h3>The certificate problem</h3><p>Now we encounter an interesting problem.</p><p>Caddy can normally request certificates automatically from a certificate authority such as Let’s Encrypt.</p><p>For a public web server, validation often works like this:</p><pre>Certificate Authority<br>        |<br>        | HTTP request<br>        v<br>example.com</pre><p>The certificate authority verifies that the server controls the hostname.</p><p>But our internal service may only be reachable at:</p><pre>100.100.50.20</pre><p>The public Internet cannot connect to that address.</p><p>So HTTP-based validation will not work.</p><p>This is where <strong>DNS-01 validation</strong> becomes useful.</p><h3>Understanding DNS-01</h3><p>A certificate authority does not necessarily need to connect to your web server.</p><p>It only needs proof that you control the domain.</p><p>DNS-01 proves domain ownership by creating a temporary DNS TXT record.</p><p>Suppose Caddy requests a certificate for:</p><pre>app.internal.example.com</pre><p>The certificate authority asks for something conceptually like:</p><pre>_acme-challenge.app.internal.example.com</pre><p>with a particular TXT value:</p><pre>TXT &quot;random-validation-token&quot;</pre><p>Caddy creates that record using your DNS provider’s API.</p><p>The certificate authority queries public DNS:</p><pre>_acme-challenge.app.internal.example.com</pre><p>If the expected TXT value exists, domain ownership has been proven.</p><p>The certificate can then be issued.</p><p>The application server itself never needed to be publicly reachable.</p><p>That makes DNS-01 ideal for:</p><ul><li>private services</li><li>VPN-only systems</li><li>internal dashboards</li><li>homelabs</li><li>wildcard certificates</li><li>private reverse proxies</li></ul><h3>The subtle part: private DNS and public DNS coexist</h3><p>At first this can sound contradictory.</p><p>How can the application hostname be private while certificate validation uses public DNS?</p><p>Because two different DNS records are involved.</p><p>The private resolver answers:</p><pre>app.internal.example.com<br>        |<br>        v<br>100.100.50.20</pre><p>Meanwhile the public DNS provider temporarily answers:</p><pre>_acme-challenge.app.internal.example.com<br>        |<br>        v<br>TXT validation-token</pre><p>These serve completely different purposes.</p><p>Runtime lookup:</p><pre>app.internal.example.com</pre><p>can remain private.</p><p>Certificate validation:</p><pre>_acme-challenge.app.internal.example.com</pre><p>can use public DNS.</p><p>You do not need to publish the application’s private IP in public DNS.</p><h3>Example architecture</h3><p>Assume:</p><pre>Domain:<br>example.com</pre><pre>Private namespace:<br>internal.example.com</pre><pre>Tailscale server IP:<br>100.100.50.20</pre><pre>Application:<br>127.0.0.1:4000</pre><p>We want:</p><pre>https://app.internal.example.com</pre><p>The complete flow is:</p><pre>DNS LOOKUP</pre><pre>Laptop<br>   |<br>   | app.internal.example.com<br>   v<br>Tailscale DNS<br>   |<br>   | internal.example.com<br>   v<br>dnsmasq<br>100.100.50.20:53<br>   |<br>   | returns<br>   v<br>100.100.50.20<br></pre><pre>              APPLICATION REQUEST</pre><pre>Laptop<br>   |<br>   | HTTPS over private network<br>   v<br>100.100.50.20:443<br>   |<br>   v<br>Caddy<br>   |<br>   v<br>127.0.0.1:4000</pre><p>Certificate issuance happens separately:</p><pre>Caddy<br>  |<br>  | ACME request<br>  v<br>Certificate Authority</pre><pre>Caddy<br>  |<br>  | DNS provider API<br>  v<br>DNS provider<br>  |<br>  | creates TXT record<br>  v<br>_acme-challenge.app.internal.example.com</pre><pre>Certificate Authority<br>  |<br>  | verifies TXT record<br>  v<br>certificate issued</pre><h3>Step 1: Create the private DNS server</h3><p>One lightweight choice is dnsmasq.</p><p>A minimal configuration might look like:</p><pre>interface=tailscale0<br>bind-dynamic<br><br>address=/internal.example.com/100.100.50.20<br><br>no-resolv<br>no-hosts</pre><p>The important line is:</p><pre>address=/internal.example.com/100.100.50.20</pre><p>It effectively means:</p><pre>anything.internal.example.com<br>        -&gt;<br>100.100.50.20</pre><p>So you can later add:</p><pre>app.internal.example.com<br>grafana.internal.example.com<br>git.internal.example.com<br>monitoring.internal.example.com</pre><p>without changing DNS configuration.</p><p>Caddy handles the application-level routing.</p><h3>Step 2: Run dnsmasq only on the private interface</h3><p>You generally do not want your internal DNS server listening on every network interface.</p><p>Bind it specifically to the private network.</p><p>For Tailscale that might mean:</p><pre>interface=tailscale0<br>bind-dynamic</pre><p>The expected result is something similar to:</p><pre>100.100.50.20:53 -&gt; dnsmasq</pre><p>Your operating system may already have another DNS resolver listening on loopback, for example:</p><pre>127.0.0.53:53</pre><p>That is fine.</p><p>Different services can coexist as long as they bind different addresses.</p><p>For example:</p><pre>system DNS resolver<br>    -&gt; 127.0.0.53:53<br><br>shprivate dnsmasq<br>    -&gt; 100.100.50.20:53</pre><h3>Step 3: Configure split DNS in Tailscale</h3><p>Tell the private network that requests for:</p><pre>internal.example.com</pre><p>should go to:</p><pre>100.100.50.20</pre><p>Conceptually:</p><pre>DNS server: 100.100.50.20<br>Domain:     internal.example.com</pre><p>Now a connected client asking for:</p><pre>app.internal.example.com</pre><p>follows:</p><pre>Client<br>   |<br>   v<br>Tailscale DNS<br>   |<br>   v<br>Private dnsmasq<br>   |<br>   v<br>100.100.50.20</pre><p>Whereas:</p><pre>google.com</pre><p>continues through normal DNS.</p><p>Test it from another private-network device:</p><pre>dig app.internal.example.com</pre><p>You should receive:</p><pre>100.100.50.20</pre><p>You can also query dnsmasq directly:</p><pre>dig @100.100.50.20 app.internal.example.com</pre><h3>Step 4: Put Caddy in front of the application</h3><p>Your application should ideally listen only locally:</p><pre>127.0.0.1:4000</pre><p>Then configure Caddy:</p><pre>app.internal.example.com {<br>    reverse_proxy 127.0.0.1:4000<br>}</pre><p>Now:</p><pre>https://app.internal.example.com</pre><p>can map to:</p><pre>127.0.0.1:4000</pre><p>without exposing port 4000 to clients.</p><p>For several applications:</p><pre>app.internal.example.com {<br>    reverse_proxy 127.0.0.1:4000<br>}<br><br>grafana.internal.example.com {<br>    reverse_proxy 127.0.0.1:3000<br>}<br>git.internal.example.com {<br>    reverse_proxy 127.0.0.1:8080<br>}</pre><p>The reverse proxy becomes the routing layer.</p><h3>Step 5: Restrict Caddy to the private network</h3><p>By default, a server listening on:</p><pre>:443</pre><p>may accept connections on multiple network interfaces.</p><p>For a strictly private service, you can bind Caddy specifically to the private address:</p><pre>app.internal.example.com {<br>    bind 100.100.50.20<br>    reverse_proxy 127.0.0.1:4000<br>}</pre><p>Now the service is explicitly listening on the Tailscale address rather than a public LAN or WAN interface.</p><p>A firewall can provide another layer of protection:</p><pre>allow TCP 443 on tailscale0<br>allow TCP/UDP 53 on tailscale0<br>deny those services elsewhere</pre><p>This is defense in depth.</p><h3>Step 6: Enable DNS-01 certificate issuance</h3><p>Caddy needs a DNS provider integration that can create TXT records automatically.</p><p>For a provider such as Cloudflare, Caddy can use a DNS module.</p><p>Conceptually:</p><pre>app.internal.example.com {<br>    tls {<br>        dns cloudflare {env.DNS_API_TOKEN}<br>    }<br><br>    reverse_proxy 127.0.0.1:4000<br>}</pre><p>The API token should have only the minimum permissions required to modify DNS records for the relevant zone.</p><p>For example:</p><pre>DNS records: Edit<br>Zone metadata: Read</pre><p>and ideally only for:</p><pre>example.com</pre><p>Do not use an unrestricted account-wide API key if a scoped token is available.</p><p>Store the token outside the Caddyfile, for example through:</p><ul><li>systemd environment variables</li><li>a protected environment file</li><li>a secrets manager</li></ul><p>The important principle is:</p><pre>configuration references secret<br>configuration does not contain secret</pre><h3>Step 7: Understand what happens during certificate issuance</h3><p>When Caddy starts:</p><pre>Caddy<br>  |<br>  | certificate requested<br>  v<br>ACME server</pre><p>The ACME server requests DNS validation.</p><p>Caddy then calls the DNS provider API:</p><pre>Caddy<br>  |<br>  v<br>DNS API<br>  |<br>  v<br>create:</pre><pre>_acme-challenge.app.internal.example.com</pre><pre>TXT = ...</pre><p>The certificate authority verifies the record.</p><p>Then:</p><pre>validation succeeds<br>        |<br>        v<br>certificate issued<br>        |<br>        v<br>Caddy stores certificate</pre><p>Caddy subsequently presents that certificate to private clients.</p><p>The browser sees a perfectly normal trusted HTTPS certificate even though the server itself is inaccessible from the Internet.</p><h3>Step 8: Test layer by layer</h3><p>When debugging this architecture, avoid testing everything simultaneously.</p><p>Start with DNS.</p><h3>Private DNS</h3><pre>dig app.internal.example.com</pre><p>Expected:</p><pre>100.100.50.20</pre><p>Then private network connectivity:</p><pre>tailscale ping 100.100.50.20</pre><p>Then TCP connectivity:</p><pre>nc -vz 100.100.50.20 443</pre><p>Then TLS:</p><pre>openssl s_client \<br>  -connect 100.100.50.20:443 \<br>  -servername app.internal.example.com</pre><p>Finally HTTP:</p><pre>curl -v https://app.internal.example.com</pre><p>Thinking in layers makes failures much easier to diagnose.</p><p>For example:</p><pre>DNS works<br>TCP connection works<br>TLS fails</pre><p>means your problem is probably certificate or reverse-proxy configuration — not Tailscale.</p><p>Similarly:</p><pre>DNS returns correct IP<br>connection times out</pre><p>points toward routing, ACLs, firewall rules, or the listening socket.</p><h3>A useful mental model</h3><p>This architecture becomes much easier to understand if you separate responsibility.</p><h3>Tailscale</h3><p>Provides:</p><pre>private connectivity<br>encryption<br>device identity<br>network access control</pre><p>It does not need to know anything about your application URLs.</p><h3>dnsmasq</h3><p>Provides:</p><pre>hostname -&gt; private IP</pre><p>It does not proxy application traffic.</p><h3>Caddy</h3><p>Provides:</p><pre>HTTPS termination<br>hostname routing<br>reverse proxying<br>certificate automation</pre><h3>Public DNS provider</h3><p>Provides:</p><pre>domain ownership<br>DNS-01 validation records</pre><p>It does not need to carry your application traffic.</p><h3>Certificate authority</h3><p>Provides:</p><pre>browser-trusted TLS certificates</pre><p>Once the pieces are separated like this, the architecture stops feeling complicated.</p><h3>Why not just use Tailscale’s built-in HTTPS?</h3><p>Tailscale can provide HTTPS for names under its own DNS namespace.</p><p>For many setups, that is the easiest solution.</p><p>For example:</p><pre>https://machine-name.example-tailnet.ts.net</pre><p>may be sufficient.</p><p>Using your own private domain makes more sense when you want:</p><ul><li>stable application-oriented hostnames</li><li>independence from the VPN provider’s naming scheme</li><li>one reverse proxy for many services</li><li>names such as grafana.internal.example.com</li><li>the option to replace Tailscale later without changing every application URL</li></ul><p>It introduces more DNS and certificate configuration, but gives you a cleaner abstraction.</p><p>Applications depend on:</p><pre>app.internal.example.com</pre><p>rather than:</p><pre>particular-host.particular-vpn-provider-domain</pre><p>That can be valuable as a homelab or private infrastructure grows.</p><h3>Avoid publishing private IPs unless you intentionally want to</h3><p>A simpler alternative is placing this directly in public DNS:</p><pre>app.internal.example.com -&gt; 100.100.50.20</pre><p>Technically, only private-network devices will generally be able to reach that address.</p><p>But it has drawbacks:</p><ul><li>your internal hostnames become publicly visible</li><li>private addressing becomes visible</li><li>some DNS systems have rebinding protections</li><li>internal and external namespaces become mixed</li><li>architecture becomes harder to reason about</li></ul><p>Split DNS gives cleaner separation:</p><pre>Public DNS:<br>example.com<br><br>Private DNS:<br>internal.example.com</pre><p>That is generally preferable for private infrastructure.</p><h3>Wildcard private DNS makes the system easy to extend</h3><p>One particularly useful pattern is:</p><pre>*.internal.example.com<br>        -&gt;<br>100.100.50.20</pre><p>Then adding an application requires only a Caddy entry.</p><p>For example:</p><pre>photos.internal.example.com {<br>    reverse_proxy 127.0.0.1:2342<br>}<br><br>monitor.internal.example.com {<br>    reverse_proxy 127.0.0.1:3001<br>}<br>automation.internal.example.com {<br>    reverse_proxy 127.0.0.1:5678<br>}</pre><p>DNS does not need to change.</p><p>Conceptually:</p><pre>*.internal.example.com<br>          |<br>          v<br>        Caddy<br>       /  |  \<br>      /   |   \<br> photos monitor automation</pre><p>This is essentially an internal ingress layer.</p><h3>You can also use wildcard TLS certificates</h3><p>DNS-01 has another useful capability: wildcard certificates.</p><p>For example:</p><pre>*.internal.example.com</pre><p>can be validated using DNS-01.</p><p>That means one certificate can cover:</p><pre>app.internal.example.com<br>grafana.internal.example.com<br>notes.internal.example.com</pre><p>Whether you should use a wildcard certificate or let Caddy manage individual certificates is an operational choice.</p><p>Individual certificates have tighter scope.</p><p>Wildcard certificates simplify environments with many dynamically created hostnames.</p><h3>Keep application ports private</h3><p>One subtle security improvement is ensuring backends listen only on loopback whenever possible.</p><p>Prefer:</p><pre>127.0.0.1:4000</pre><p>instead of:</p><pre>0.0.0.0:4000</pre><p>Then the only externally reachable entry point is Caddy:</p><pre>Private client<br>      |<br>      | :443<br>      v<br>    Caddy<br>      |<br>      | localhost<br>      v<br>application</pre><p>This reduces the number of exposed network surfaces.</p><p>For Docker applications, a similar pattern can be achieved by:</p><ul><li>placing Caddy and applications on a shared Docker network, or</li><li>binding container ports only to localhost</li></ul><p>instead of exposing every container to the host’s external interfaces.</p><h3>Be careful with port 443 ownership</h3><p>Only one process can normally listen on the same address and TCP port combination.</p><p>For example, if Tailscale Serve already owns:</p><pre>100.100.50.20:443</pre><p>Caddy cannot also bind there.</p><p>You may see an error such as:</p><pre>listen tcp :443: bind: address already in use</pre><p>Check with:</p><pre>ss -lntp | grep &#39;:443&#39;</pre><p>Decide which component should own HTTPS.</p><p>If Caddy is your reverse proxy, a clean design is:</p><pre>443 -&gt; Caddy</pre><p>with Tailscale providing only network connectivity.</p><p>Avoid accidentally running two independent HTTPS ingress layers on the same socket.</p><h3>systemd is useful for the supporting services</h3><p>Private DNS and reverse proxies are infrastructure services, so they should survive:</p><ul><li>logout</li><li>SSH disconnection</li><li>crashes</li><li>reboot</li></ul><p>Running them under systemd makes this straightforward.</p><p>A dedicated dnsmasq service might conceptually contain:</p><pre>[Unit]<br>Description=Private DNS<br>After=tailscaled.service<br>Requires=tailscaled.service<br><br>[Service]<br>ExecStart=/usr/sbin/dnsmasq \<br>    --no-daemon \<br>    --conf-file=/etc/private-dns/dnsmasq.conf<br>Restart=on-failure<br><br>[Install]<br>WantedBy=multi-user.target</pre><p>The dependency is useful because the private Tailscale address may not exist until Tailscale has initialized.</p><p>For dynamically appearing interfaces, dnsmasq’s dynamic binding behavior can also be useful.</p><h3>A production-style version of the architecture</h3><p>Even for a homelab, it is useful to think in terms of trust boundaries.</p><p>A clean design looks like this:</p><pre>                        Internet<br>                           |<br>                   certificate authority<br>                           |<br>                      Public DNS<br>                           ^<br>                           |<br>                    DNS API validation<br>                           |<br>                           |<br>                        Caddy<br>                          ^<br>                          |<br>              private encrypted network<br>                          |<br>                    Tailscale clients</pre><p>Application traffic never crosses the public Internet directly.</p><p>Only certificate-validation metadata reaches public DNS.</p><p>Inside the server:</p><pre>tailscale0<br>100.100.50.20<br>      |<br>      +---- UDP/TCP 53 ---- dnsmasq<br>      |<br>      +---- TCP 443 -------- Caddy<br>                              |<br>                              +--&gt; localhost:3000<br>                              +--&gt; localhost:4000<br>                              +--&gt; localhost:8080</pre><p>This gives you a small internal platform rather than a collection of arbitrary open ports.</p><h3>Final configuration pattern</h3><p>A practical generic setup could therefore look like:</p><h3>Private DNS</h3><pre>interface=tailscale0<br>bind-dynamic<br><br>address=/internal.example.com/100.100.50.20<br>no-resolv<br>no-hosts</pre><h3>Tailscale DNS</h3><pre>Restricted domain:<br>internal.example.com<br><br>Resolver:<br>100.100.50.20</pre><h3>Caddy</h3><pre>app.internal.example.com {<br>    bind 100.100.50.20<br><br>    tls {<br>        dns cloudflare {env.DNS_API_TOKEN}<br>    }<br><br>    reverse_proxy 127.0.0.1:4000<br>}<br><br>monitoring.internal.example.com {<br>    bind 100.100.50.20<br><br>    tls {<br>        dns cloudflare {env.DNS_API_TOKEN}<br>    }<br><br>    reverse_proxy 127.0.0.1:3000<br>}</pre><h3>Network exposure</h3><pre>tailscale0:<br>    TCP 443<br>    TCP/UDP 53<br><br>localhost:<br>    application ports</pre><p>The exact software can change.</p><p>You could replace:</p><ul><li>Tailscale with another private overlay network</li><li>dnsmasq with Unbound, CoreDNS, Pi-hole, or another resolver</li><li>Cloudflare with another DNS provider</li><li>Caddy with nginx, Traefik, HAProxy, Envoy, or another reverse proxy</li><li>Let’s Encrypt with another ACME-compatible certificate authority</li></ul><p>The underlying design remains the same.</p><h3>The broader networking idea</h3><p>The most useful lesson from this setup is that <strong>reachability, naming, routing, and identity are separate layers</strong>.</p><p>Tailscale answers:</p><blockquote><em>Who can reach this machine?</em></blockquote><p>DNS answers:</p><blockquote><em>What IP should this hostname map to?</em></blockquote><p>Caddy answers:</p><blockquote><em>Which application should receive this HTTPS request?</em></blockquote><p>TLS answers:</p><blockquote><em>Can the client authenticate the hostname and establish a secure browser origin?</em></blockquote><p>DNS-01 answers:</p><blockquote><em>How can we prove ownership of a hostname when the web server itself isn’t publicly reachable?</em></blockquote><p>Once those responsibilities are separated, private hosting becomes much easier to reason about.</p><p>You can have all the conveniences of a normal web platform:</p><pre>https://app.internal.example.com</pre><p>while keeping the actual service reachable only over your private network.</p><p>That is a useful pattern not just for homelabs, but also for internal development environments, admin consoles, observability stacks, staging systems, and small private infrastructure deployments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b1c57bccaff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your Service Needs Three Health Checks, Not One]]></title>
            <link>https://medium.com/@abhirajsinghtomar/your-service-needs-three-health-checks-not-one-21ffa6a0a4d8?source=rss-9bcf1f03e405------2</link>
            <guid isPermaLink="false">https://medium.com/p/21ffa6a0a4d8</guid>
            <category><![CDATA[observability]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[design-systems]]></category>
            <category><![CDATA[monitoring]]></category>
            <dc:creator><![CDATA[abhiraj singh tomar]]></dc:creator>
            <pubDate>Mon, 07 Sep 2026 20:53:40 GMT</pubDate>
            <atom:updated>2026-09-07T20:54:17.208Z</atom:updated>
            <content:encoded><![CDATA[<h4>Why one /health endpoint causes outages, and what to expose instead for Docker and Kubernetes.</h4><p>Most services start with one /health endpoint. It runs SELECT 1 on the database, pings Redis, and returns 200 if both answer. Then it gets wired into everything: Docker, Kubernetes probes, the load balancer, the uptime monitor.</p><p>This works until the database has a bad five minutes. Every instance fails its health check. Kubernetes restarts all of them. The restarts hit the recovering database. A small blip becomes a full outage.</p><p>The fix is not a smarter /health. The fix is realising that &quot;is this service healthy?&quot; is three different questions, asked by three different callers, with three different results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F6_7MDQljsgBw46pf64Ygw.png" /></figure><h3>Three questions, three endpoints</h3><p><strong>Is this process alive?</strong> Kubernetes asks this. If the answer is no, it restarts the container. This is the <em>liveness</em> check.</p><p><strong>Should this instance get traffic right now?</strong> Kubernetes and the load balancer ask this. If no, they stop sending requests but leave the instance running. This is the <em>readiness</em> check.</p><p><strong>How is the service and everything it depends on doing?</strong> Humans, dashboards, and uptime monitors ask this. If no, someone gets paged. This is the <em>deep health</em> check.</p><p>I’ll call them /health/live, /health/ready, and /health/deep. You&#39;ll also see /livez, /readyz, and /healthz in the wild. The z comes from Google, whose internal servers used paths like /healthz and /varz so they wouldn&#39;t clash with real app routes, and Kubernetes copied it. Most application frameworks (Spring, Quarkus, MicroProfile, ASP.NET) went with a /health prefix instead. The names don&#39;t matter. The separation does, and a shared prefix makes it easy to apply one routing, auth, or logging rule to all of them.</p><h3>Liveness: check almost nothing</h3><p>Liveness answers one question: would a human kill -9 this process? That&#39;s a high bar, and it should be. Every failure means a restart, and restarts under load usually make things worse.</p><p>Check these:</p><ul><li>The HTTP server can respond</li><li>Critical background workers are still running</li><li>Maybe: the main loop has ticked recently (a simple watchdog timestamp)</li></ul><p>Never check these:</p><ul><li>The database</li><li>The cache</li><li>Any other service</li><li>Anything shared with other instances</li></ul><p>Simple rule: if the same condition would fail on every instance at the same time, it doesn’t belong in liveness. Restarting 100 pods does nothing for a database outage. It just means 100 cold processes hit the database at once when it comes back.</p><pre>func live(w http.ResponseWriter, r *http.Request) {<br>    // If the main loop hasn&#39;t ticked in a minute, we&#39;re stuck.<br>    if time.Since(watchdog.LastTick()) &gt; 60*time.Second {<br>        http.Error(w, &quot;wedged&quot;, http.StatusServiceUnavailable)<br>        return<br>    }<br>    w.WriteHeader(http.StatusOK)<br>}</pre><h3>Readiness: only what’s local to this instance</h3><p>Readiness answers: can <em>this specific instance</em> handle a request right now? Failing it is gentle. Traffic goes elsewhere and the instance keeps running. So this is the place for things that are truly per-instance.</p><p>Check these:</p><ul><li>Startup is done: config loaded, connection pools created, caches warmed if you need them</li><li>The instance is not shutting down</li><li>Local resources work: this pod’s connection pool came up, this pod’s disk has space</li></ul><p>The tempting mistake is adding shared dependencies here. “If the database is down, this pod can’t serve, so mark it not ready.” Sounds right. But look at what actually happens: every instance fails readiness at once, the load balancer has zero healthy targets, and users get a blank 503 from the edge instead of a real error from your app. You lost a clear error signal and gained nothing. The pods couldn’t serve anyway.</p><p>Keep shared dependencies out of readiness. Let your app return proper errors when it can’t reach the database. Your error rate graph will tell you what’s wrong far better than a fleet of unready pods.</p><p>One exception: if <em>this</em> pod’s connection pool is broken while other pods are fine, failing readiness is correct. The difference is “I can’t reach it from here” versus “it’s down for everyone.”</p><pre>var ready atomic.Bool  // false at boot, true after init, false again on shutdown<br><br>func ready(w http.ResponseWriter, r *http.Request) {<br>    if !ready.Load() {<br>        http.Error(w, &quot;not ready&quot;, http.StatusServiceUnavailable)<br>        return<br>    }<br>    w.WriteHeader(http.StatusOK)<br>}</pre><h3>Deep health: check dependencies, but not in the handler</h3><p>/health/deep is where dependency checks go. It reports each dependency and an overall verdict. This is what your uptime monitor hits.</p><p>The key rule: <strong>don’t run the checks inside the handler.</strong> If the handler queries the database every call, the cost grows with probe frequency times instance count. Worse, a slow database makes the endpoint slow, the monitor times out, and it reports “down” when things are just degraded.</p><p>Instead, run a background loop that checks dependencies on its own schedule with short timeouts, and store the result. The handler just returns the stored result. Now probe frequency and instance count have no effect on your database, and the endpoint stays fast no matter what.</p><pre>type DepStatus string<br><br>const (<br>    StatusOK       DepStatus = &quot;ok&quot;<br>    StatusDegraded DepStatus = &quot;degraded&quot;<br>    StatusDown     DepStatus = &quot;down&quot;<br>)<br><br>type Snapshot struct {<br>    DB        DepStatus `json:&quot;db&quot;`<br>    Cache     DepStatus `json:&quot;cache&quot;`<br>    CheckedAt time.Time `json:&quot;checked_at&quot;`<br>}<br><br>var snapshot atomic.Pointer[Snapshot]<br><br>func runHealthChecker(ctx context.Context, db *sql.DB, cache *redis.Client) {<br>    t := time.NewTicker(10 * time.Second)<br>    defer t.Stop()<br>    for {<br>        s := Snapshot{CheckedAt: time.Now()}<br><br>        dbCtx, cancel := context.WithTimeout(ctx, 2*time.Second)<br>        if err := db.PingContext(dbCtx); err != nil {<br>            s.DB = StatusDown<br>        } else {<br>            s.DB = StatusOK<br>        }<br>        cancel()<br><br>        cacheCtx, cancel := context.WithTimeout(ctx, 1*time.Second)<br>        if err := cache.Ping(cacheCtx).Err(); err != nil {<br>            s.Cache = StatusDegraded // we can live without cache; change if you can&#39;t<br>        } else {<br>            s.Cache = StatusOK<br>        }<br>        cancel()<br><br>        snapshot.Store(&amp;s)<br>        select {<br>        case &lt;-t.C:<br>        case &lt;-ctx.Done():<br>            return<br>        }<br>    }<br>}<br>func deep(w http.ResponseWriter, r *http.Request) {<br>    s := snapshot.Load()<br>    code := http.StatusOK<br>    if s == nil || s.DB == StatusDown {<br>        code = http.StatusServiceUnavailable<br>    }<br>    w.Header().Set(&quot;Content-Type&quot;, &quot;application/json&quot;)<br>    w.WriteHeader(code)<br>    json.NewEncoder(w).Encode(s)<br>}</pre><p>Two things to notice.</p><p>First, whether a failed check means Degraded or Down is a decision, not a fact. Losing the cache is usually fine. Losing the primary database usually isn&#39;t. Write the decision down in code instead of treating every failure the same.</p><p>Second, the snapshot has a checked_at timestamp. If the background loop dies, the result goes stale instead of staying green forever. You can even feed this into liveness: a snapshot older than a minute means a core background task is stuck, and that&#39;s a fair reason to restart.</p><h3>Graceful shutdown: readiness is the switch</h3><p>Pods get stopped all the time, and not just by your own deploys. A rolling update, a node drain, a cluster autoscaler scaling down, or AWS reclaiming a spot instance all end the same way: Kubernetes sends SIGTERM and removes the pod from service discovery at the same time. Not one after the other. So for a few seconds the pod is still getting new requests while being told to stop.</p><p>This is separate from liveness. Liveness is your app telling Kubernetes it’s stuck. SIGTERM is Kubernetes (or the cloud provider behind it) telling your app to leave. Your app doesn&#39;t get a vote on the second one, only a little time to leave cleanly.</p><p>Here’s the order that avoids dropped requests:</p><ol><li>On SIGTERM, set readiness to false right away. The next probe pulls the pod out of rotation.</li><li>Wait a few seconds. Load balancers and service discovery take time to notice. Five to ten seconds is typical.</li><li>Stop accepting new connections. Finish in-flight requests with a deadline.</li><li>Close connection pools. Exit.</li></ol><pre>func main() {<br>    // ... create pools, start background checker ...<br>    ready.Store(true)<br>    <br>    srv := &amp;http.Server{Addr: &quot;:8080&quot;, Handler: mux}<br>    go srv.ListenAndServe()<br>    <br>    sig := make(chan os.Signal, 1)<br>    signal.Notify(sig, syscall.SIGTERM, syscall.SIGINT)<br>    &lt;-sig<br>    <br>    ready.Store(false)                 // step 1: fail readiness<br>    time.Sleep(5 * time.Second)        // step 2: let routing catch up<br>    <br>    ctx, cancel := context.WithTimeout(context.Background(), 25*time.Second)<br>    defer cancel()<br>    srv.Shutdown(ctx)                  // step 3: stop accepting, drain<br><br>    db.Close()                         // step 4: clean up<br>}</pre><p>The wait in step 2 can live in your app or in a Kubernetes preStop hook. The hook is better. It runs <em>before</em> SIGTERM is sent, so the order is guaranteed instead of a race.</p><h3>Docker</h3><p>Docker has one HEALTHCHECK. It fits readiness best, because Docker (and Compose&#39;s depends_on: condition: service_healthy) uses it to decide when a container is usable, not whether to restart it. Docker won&#39;t restart on health failure unless you add something external.</p><pre>HEALTHCHECK --interval=10s --timeout=3s --start-period=30s --retries=3 \<br>  CMD curl -fsS http://localhost:8080/health/ready || exit 1</pre><p>start-period gives the container time to boot before failures count. Set it to your slowest realistic cold start.</p><h3>Kubernetes</h3><p>Kubernetes has three probes, and they map straight onto the three endpoints.</p><pre>spec:<br>  terminationGracePeriodSeconds: 45<br>  containers:<br>    - name: app<br>      ports:<br>        - containerPort: 8080<br>      startupProbe:<br>        httpGet: { path: /health/ready, port: 8080 }<br>        periodSeconds: 2<br>        failureThreshold: 60      # up to 120s for slow boots<br>      livenessProbe:<br>        httpGet: { path: /health/live, port: 8080 }<br>        periodSeconds: 10<br>        timeoutSeconds: 2<br>        failureThreshold: 3       # ~30s of failure before restart<br>      readinessProbe:<br>        httpGet: { path: /health/ready, port: 8080 }<br>        periodSeconds: 5<br>        timeoutSeconds: 2<br>        failureThreshold: 2       # ~10s before pulled from rotation<br>        successThreshold: 1<br>      lifecycle:<br>        preStop:<br>          exec:<br>            command: [&quot;sh&quot;, &quot;-c&quot;, &quot;sleep 8&quot;]</pre><h3>Picking the numbers</h3><p><strong>Startup probe.</strong> Its only job is to hold liveness back until boot is done. Make the total window (periodSeconds × failureThreshold) bigger than your slowest cold start, including warmup, migrations, and waiting for dependencies. Too tight and you get a crash loop that looks like an app bug.</p><p><strong>Liveness.</strong> Fail slowly. 10 seconds × 3 failures means a pod has to be dead for about 30 seconds before restart. That’s enough to survive a GC pause or a traffic spike. Don’t tighten this without a real reason.</p><p><strong>Readiness.</strong> A bit faster, but not jumpy. A threshold of 1 with a short timeout pulls a healthy pod out during a small stall, which pushes its load onto the others and can snowball. Two failures over ten seconds is a good default.</p><p><strong>Timeouts.</strong> Keep them short (1 to 3 seconds) and make sure your handlers can hit them. Health handlers must not share a lock, thread pool, or queue with normal requests. Otherwise a probe waits behind busy request handlers and reports the pod as dead when it’s just busy.</p><p><strong>Grace period.</strong> Must be longer than preStop sleep + drain deadline + cleanup. If it&#39;s not, Kubernetes sends SIGKILL mid-drain and you drop requests anyway.</p><h3>Things that will bite you</h3><p><strong>Don’t expose the detailed health page publicly.</strong> A /health/deep body listing your dependencies is handy internally and a gift to attackers externally. Serve it on a separate admin port that isn&#39;t routed through the public ingress, or return just a status code on the public route. The admin port is also a good home for /metrics.</p><p><strong>Uptime monitors check the front door, not the service.</strong> Hitting /health/deep through your public URL tests DNS, TLS, the load balancer, the ingress, and the app together. That&#39;s useful but coarse. Also alert internally on the fraction of pods that are unready, so you notice half the fleet dropping before the monitor does.</p><p><strong>Autoscaling reacts to readiness.</strong> Unready pods get no traffic, which shifts load and confuses the autoscaler’s metrics. If readiness fails on a shared dependency, the autoscaler might see low CPU and scale <em>down</em> right before the dependency comes back. One more reason to keep shared dependencies out of readiness.</p><p><strong>Rollouts wait on readiness.</strong> A rolling update waits for new pods to pass readiness before killing old ones. With a preStop sleep and a long grace period, a big deployment takes minutes to roll. That&#39;s fine. Just do the math so nobody panics.</p><p><strong>Health checks are not your database load problem.</strong> 100 instances pinging every 10 seconds is 10 queries per second of SELECT 1. That&#39;s nothing. 100 instances with a pool of 20 each is 2,000 connections. That&#39;s the real problem. If database load worries you, look at pool sizes and a connection pooler first.</p><h3>Summary</h3><ul><li>Three endpoints, three callers, three results: /health/live restarts, /health/ready removes from rotation, /health/deep pages a human.</li><li>Liveness checks nothing shared. If it would fail everywhere at once, it doesn’t belong there.</li><li>Readiness is about this instance only: booted, not shutting down, local resources fine. Shared dependency outages should produce app errors, not unready pods.</li><li>Deep health checks dependencies in a background loop with short timeouts. The handler returns a cached result with a timestamp.</li><li>Shutdown flips readiness first, waits for routing to catch up, then drains.</li><li>Fail liveness slowly, readiness moderately, and make the grace period long enough to actually finish.</li></ul><p>Get this right and a dependency having a bad day stays a dependency having a bad day, instead of becoming your outage.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21ffa6a0a4d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Replaced Obsidian Sync with a Self-Hosted CouchDB Server - Here’s How You Can Too]]></title>
            <link>https://medium.com/@abhirajsinghtomar/i-replaced-obsidian-sync-with-a-self-hosted-couchdb-server-heres-how-you-can-too-9d2f1aaa1f62?source=rss-9bcf1f03e405------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d2f1aaa1f62</guid>
            <category><![CDATA[obsidiansync]]></category>
            <category><![CDATA[tailscale]]></category>
            <category><![CDATA[obsidian]]></category>
            <category><![CDATA[live-sync]]></category>
            <category><![CDATA[notes]]></category>
            <dc:creator><![CDATA[abhiraj singh tomar]]></dc:creator>
            <pubDate>Sun, 05 Apr 2026 21:27:59 GMT</pubDate>
            <atom:updated>2026-04-05T21:27:59.466Z</atom:updated>
            <content:encoded><![CDATA[<h3>Free, real-time, end-to-end encrypted note sync across Mac, iPhone, and iPad using Docker, CouchDB, and Tailscale.</h3><p>I’ve been using Obsidian for almost a year. It’s the best note-taking tool I’ve found - local Markdown files, no vendor lock-in, incredible plugin ecosystem. But there’s one problem that’s plagued me the entire time: <strong>sync</strong>.</p><p>Obsidian Sync costs $5/month. Not unreasonable, but I like to self-host. I tried using <strong>GitHub</strong> as a workaround - commit and push from one device, pull on the other. It worked until it didn’t. Merge conflicts, failed pulls on iOS, notes stuck in a bad state. If you’ve tried the Git approach, you know the pain.</p><p>I’m fully in the Apple ecosystem (Mac, iPhone, iPad) and I have a Linux home server. After researching every free option -iCloud, Syncthing, Remotely Save, I landed on <strong>Self-hosted LiveSync with CouchDB</strong>, and it’s been flawless. Real-time sync, smart conflict merging, works natively on iOS without third-party apps, and my data never touches anyone else’s servers.</p><p>This is the complete guide I wish I had when I started.</p><h3>Why Not the Other Options?</h3><p>Before we dive in, a quick rundown of why the alternatives didn’t cut it:</p><p><strong>iCloud</strong> - Zero setup, but unreliable. iOS decides when to sync based on battery, network, and thermal state. Files get offloaded to .icloud stubs. Conflict handling is &quot;silently overwrite one version.&quot; And the dealbreaker: no Linux support, so my server can&#39;t participate.</p><p><strong>Git/GitHub</strong> - Works until you edit on two devices without pulling first. Then you’re resolving merge conflicts in your notes. On iOS, there’s no good native Git client that integrates with Obsidian reliably.</p><p><strong>Syncthing</strong> - Excellent tool, but iOS support requires Möbius Sync (~$5), which gets limited background sync time from iOS. Conflict handling is file-level - it creates .sync-conflict copies that you merge manually.</p><p><strong>Remotely Save</strong> - Solid plugin, but periodic sync only (not real-time). No background sync. Conflict resolution is basic: newer file wins.</p><p><strong>Self-hosted LiveSync</strong> is the only free option that gives you real-time sync, chunk-level conflict merging, native iOS support (it’s just an Obsidian plugin), and full self-hosting on your own server.</p><h3>How LiveSync Actually Works</h3><p>Before setup, it helps to understand the architecture. This isn’t a “copy files around” tool - it’s fundamentally different.</p><p>LiveSync embeds <strong>PouchDB</strong> (a JavaScript CouchDB client) inside Obsidian. PouchDB and CouchDB speak the same replication protocol natively. Every device runs its own PouchDB instance, and your server runs CouchDB. Sync is just two compatible databases replicating with each other.</p><p><strong>The key innovation is chunk-based storage.</strong> When you save a note, LiveSync doesn’t store the whole file as one document. It splits it into chunks using a content-defined chunking algorithm. Each chunk becomes its own CouchDB document.</p><p>Why this matters:</p><ul><li>Edit one paragraph in a long note → only that chunk syncs, not the whole file</li><li>Two devices edit <strong>different paragraphs</strong> of the same note → LiveSync auto-merges because different chunks were modified</li><li>Two devices edit the <strong>same paragraph</strong> → LiveSync shows a conflict resolver (both versions preserved, nothing lost)</li></ul><p>This is the fundamental improvement over Git, which operates at the file level and can’t distinguish “different parts of the same file” from “conflicting edits.”</p><p>In LiveSync mode, the plugin maintains a persistent connection to CouchDB’s _changes feed - a real-time stream of every database modification. Edits appear on other devices within 1–2 seconds.</p><h3>What You’ll Need</h3><ul><li>A Linux server (home server, VPS, Raspberry Pi - anything that runs Docker)</li><li>Docker and Docker Compose installed on the server</li><li>Obsidian installed on all your devices</li><li><strong>Tailscale</strong> installed on the server and all your devices (free for personal use) - this is my choice of secure and free VPN mesh. You can expose your server using tunneling solution available like tailscale, cloudflare, ngrok, etc</li></ul><p>Tailscale gives us two things: a private encrypted network between all your devices, and free automatic HTTPS certificates. Obsidian mobile requires HTTPS with a valid SSL certificate - Tailscale handles this without any domain registration, Caddy, Nginx, or Cloudflare configuration.</p><p><strong>Total cost: $0.</strong> CouchDB is open source, Docker is free, Tailscale’s personal plan is free, and the LiveSync plugin is free.</p><h3>Part 1: Deploy CouchDB on Your Server</h3><h3>Step 1 - Create the project directory</h3><p>SSH into your server and set up the workspace:</p><pre>mkdir -p ~/obsidian-livesync<br>cd ~/obsidian-livesync<br>mkdir couchdb-data couchdb-etc</pre><h3>Step 2 - Create the Docker Compose file</h3><pre>cat &gt; docker-compose.yml &lt;&lt; &#39;EOF&#39;<br>services:<br>  couchdb:<br>    image: couchdb:latest<br>    container_name: obsidian-livesync<br>    environment:<br>      - COUCHDB_USER=obsidian<br>      - COUCHDB_PASSWORD=&lt;YOUR_STRONG_PASSWORD&gt;<br>    volumes:<br>      - ./couchdb-data:/opt/couchdb/data<br>      - ./couchdb-etc:/opt/couchdb/etc/local.d<br>    ports:<br>      - &quot;127.0.0.1:5984:5984&quot;<br>    restart: unless-stopped<br>EOF</pre><p>Replace &lt;YOUR_STRONG_PASSWORD&gt; with an actual password.</p><p>A few things worth noting about this configuration:</p><p><strong>127.0.0.1:5984:5984</strong> - We&#39;re binding CouchDB to localhost only. If we wrote just 5984:5984, Docker would bind to 0.0.0.0, making CouchDB accessible from your entire LAN and potentially the internet. By restricting to 127.0.0.1, CouchDB only accepts connections from the server itself. Tailscale will proxy through localhost to provide external access securely.</p><p><strong>The volume mounts</strong> - couchdb-data persists your actual database files across container restarts and upgrades. couchdb-etc persists CouchDB&#39;s configuration. Without these, a docker compose down &amp;&amp; up would wipe everything.</p><h3>Step 3 - Start CouchDB</h3><pre>docker compose up -d</pre><p>Verify it’s running:</p><pre>curl http://127.0.0.1:5984/</pre><p>You should see:</p><pre>{&quot;couchdb&quot;:&quot;Welcome&quot;,&quot;version&quot;:&quot;3.x.x&quot;,...}</pre><p>If you get permission errors on the data directories, CouchDB runs as UID 5984 inside the container:</p><pre>sudo chown -R 5984:5984 ~/obsidian-livesync/couchdb-data ~/obsidian-livesync/couchdb-etc<br>docker compose restart</pre><h3>Step 4 - Initialize CouchDB for LiveSync</h3><p>CouchDB’s default configuration doesn’t work with LiveSync out of the box. The plugin needs specific CORS settings, authentication enforcement, and document size limits. The plugin author provides an initialization script that configures everything via CouchDB’s REST API:</p><pre>curl -s https://raw.githubusercontent.com/vrtmrz/obsidian-livesync/main/utils/couchdb/couchdb-init.sh \<br>  | hostname=http://localhost:5984 \<br>    username=obsidian \<br>    password=&lt;YOUR_STRONG_PASSWORD&gt; \<br>    bash</pre><p>You should see output ending with:</p><pre>&lt;-- Configuring CouchDB by REST APIs Done!</pre><h3>What the init script configures and why</h3><p>The script sets about a dozen CouchDB configuration values. Here are the critical ones:</p><p><strong>require_valid_user = true</strong> — Blocks anonymous access. CouchDB ships in &quot;admin party&quot; mode where everyone is an admin. Without this, anyone who discovers your URL could read, modify, and delete your notes.</p><p><strong>CORS origins</strong> — Obsidian sends requests with unusual origins: app://obsidian.md on desktop (Electron), capacitor://localhost on iOS, and http://localhost on Android. Standard CORS policies reject all of these. The script whitelists them explicitly. This is the most common failure point — if CORS isn&#39;t configured correctly, Obsidian can reach CouchDB but every actual request fails with a preflight error.</p><p><strong>max_http_request_size = 4294967296</strong> (4 GB) - CouchDB defaults to 64 MB. If you embed images or PDFs in your vault, the default would reject them.</p><p><strong>max_document_size = 50000000</strong> (50 MB) — Raises the per-document size limit for large files.</p><p>You can verify the CORS configuration was applied:</p><pre>curl -s http://localhost:5984/_node/_local/_config/cors/origins -u obsidian:&lt;YOUR_STRONG_PASSWORD&gt;<br># Should return: &quot;app://obsidian.md,capacitor://localhost,http://localhost&quot;</pre><h3>Part 2: Expose CouchDB via Tailscale HTTPS</h3><p>Obsidian mobile requires HTTPS with a valid SSL certificate. tailscale serve handles this elegantly - it provisions a Let&#39;s Encrypt certificate for your server&#39;s *.ts.net domain and proxies HTTPS traffic to your local CouchDB. No domain purchase, no Caddy, no Nginx, no Cloudflare.</p><h3>Step 5 - Enable Tailscale HTTPS serving</h3><pre>sudo tailscale serve --bg --https 443 http://127.0.0.1:5984</pre><p>This tells Tailscale to:</p><ul><li>Listen on HTTPS port 443 on your Tailscale interface</li><li>Provision an SSL certificate for &lt;your-machine&gt;.&lt;your-tailnet&gt;.ts.net</li><li>Proxy all requests to CouchDB on localhost:5984</li><li>Only accept connections from devices on your Tailnet (not the public internet)</li></ul><p>Check the status:</p><pre>tailscale serve status</pre><p>You should see something like:</p><pre>https://&lt;your-machine&gt;.&lt;your-tailnet&gt;.ts.net (tailnet only)<br>|-- / proxy http://127.0.0.1:5984</pre><h3>Step 6 - Verify HTTPS access</h3><p><strong>From another device on your Tailnet</strong></p><pre>curl https://&lt;your-machine&gt;.&lt;your-taislnet&gt;.ts.net/</pre><p>You should see the CouchDB welcome JSON over HTTPS. Test authentication too:</p><pre>curl https://&lt;your-machine&gt;.&lt;your-tailnet&gt;.ts.net/_session \<br>  -u obsidian:&lt;YOUR_STRONG_PASSWORD&gt;</pre><p>Should return:</p><pre>{&quot;ok&quot;:true,&quot;userCtx&quot;:{&quot;name&quot;:&quot;obsidian&quot;,&quot;roles&quot;:[&quot;_admin&quot;]}}</pre><h3>No firewall changes needed</h3><p>tailscale serve listens on your Tailscale interface (100.x.x.x), not on 0.0.0.0. Tailscale traffic goes through a WireGuard tunnel that bypasses UFW/iptables. You don&#39;t need to open any ports.</p><h3>[Side Note] Tailscale Serve vs Funnel</h3><p><strong>tailscale serve</strong> (what we&#39;re using) - CouchDB is only accessible from devices authenticated into your Tailnet. This is the secure default.</p><p><strong>tailscale funnel</strong> - Exposes CouchDB to the entire internet. Only needed if you access notes from devices without Tailscale. If you go this route, make sure your CouchDB password is very strong, as your database becomes publicly reachable.</p><h3>Alternative approaches for HTTPS</h3><p>If you don’t want to use Tailscale, other options include:</p><ul><li><strong>Caddy reverse proxy</strong> - Auto-provisions Let’s Encrypt certs, but requires a public domain and ports 80/443 open to the internet</li><li><strong>Cloudflare Tunnel</strong> - Exposes CouchDB through Cloudflare’s network. Works well but your data transits Cloudflare’s infrastructure, and long-polling connections for LiveSync mode can occasionally be interrupted</li><li><strong>Nginx + certbot</strong> - Manual Let’s Encrypt setup. More control, more maintenance</li></ul><p>I chose Tailscale because it’s a single command, keeps CouchDB private, and I already use Tailscale for other self-hosted services.</p><h3>Part 3: Generate the Setup URI</h3><p>The Setup URI is a single encoded string that bundles your server URL, credentials, encryption passphrase, and recommended settings - encrypted with a one-time passphrase. It eliminates manual configuration errors and makes setting up additional devices trivial.</p><h3>Step 7 - Install Deno and generate the URI</h3><pre># Install Deno if you don&#39;t have it<br>curl -fsSL https://deno.land/install.sh | sh</pre><pre># Set your connection details<br>export hostname=https://&lt;your-machine&gt;.&lt;your-tailnet&gt;.ts.net<br>export database=obsidiannotes<br>export passphrase=&lt;YOUR_E2EE_PASSPHRASE&gt;<br>export username=obsidian<br>export password=&lt;YOUR_STRONG_PASSWORD&gt;</pre><pre># Generate the Setup URI<br>deno run -A <a href="https://raw.githubusercontent.com/vrtmrz/obsidian-livesync/main/utils/flyio/generate_setupuri.ts">https://raw.githubusercontent.com/vrtmrz/obsidian-livesync/main/utils/flyio/generate_setupuri.ts</a></pre><p>Output:</p><pre>obsidian://setuplivesync?settings=%5B%22tm2DpsOE74n...%22%5D</pre><pre>Your passphrase of Setup-URI is:  patient-haze<br>This passphrase is never shown again, so please note it in a safe place.</pre><p><strong>Save both</strong> - the full obsidian:// URI and the Setup URI passphrase.</p><h3>Understanding the two passphrases</h3><p><strong>E2EE passphrase</strong> (passphrase variable) - This encrypts your actual notes. Every chunk is encrypted before it leaves your device. CouchDB only ever stores ciphertext. All devices must use the same E2EE passphrase. This is permanent - changing it requires rebuilding the remote database.</p><p><strong>Setup URI passphrase</strong> (patient-haze) - A one-time key for decrypting the Setup URI itself. The plugin author designed it this way intentionally: the URI inevitably passes through your clipboard, so its decryption key should travel through a different channel (typed from memory). This passphrase is only used once per device during setup.</p><h3>Part 4: Configure Obsidian on Each Device</h3><h3>Step 8 - Set up your Mac (first device)</h3><ol><li>Open Obsidian on your Mac</li><li>Go to <strong>Settings → Community Plugins → Browse</strong></li><li>Search for <strong>“Self-hosted LiveSync”</strong> → Install → Enable</li><li>Open the <strong>Command Palette</strong> (Cmd+P)</li><li>Search for <strong>“Use the copied setup URI”</strong></li><li>Paste the full obsidian://setuplivesync?settings=... URI</li><li>Enter the Setup URI passphrase (e.g., patient-haze)</li><li>When prompted:</li></ol><ul><li>Answer <strong>Yes</strong> to proceed</li><li>Choose <strong>“Set it up…”</strong></li><li>Select <strong>“Keep them disabled”</strong> for Customization Sync and Hidden File Sync</li></ul><p>9.<strong> Reload the app</strong> when prompted (do NOT save before reloading)</p><p>After reload, LiveSync will connect and begin pushing your vault to CouchDB. Check the status bar at the bottom - you should see a sync indicator.</p><p><strong>Why “Keep them disabled”?</strong> Customization Sync and Hidden File Sync modify the .obsidian folder across devices. Enabling them during initial setup before notes are fully synced can cause plugin settings from an empty vault to overwrite your actual settings. Safe pattern: sync notes first, then enable these features later.</p><p><strong>Why “Reload without save”?</strong> The Setup URI changes the plugin’s internal configuration. Reloading without saving forces Obsidian to restart clean and read the new config from disk, avoiding stale in-memory state.</p><h3>Step 9 - Set up iPhone and iPad</h3><p>On each iOS/iPadOS device:</p><ol><li>Make sure <strong>Tailscale is installed and connected</strong></li><li>Open Obsidian → create a <strong>new empty vault</strong> (any name works - LiveSync syncs contents, not vault names)</li><li><strong>Settings → Community Plugins</strong> → turn off Restricted Mode</li><li>Browse → search <strong>“Self-hosted LiveSync”</strong> → Install → Enable</li><li>Command Palette → <strong>“Use the copied setup URI”</strong></li><li>Paste the same Setup URI → enter the same passphrase</li><li>Follow the same prompts as the Mac setup</li><li>Reload when prompted</li></ol><p><strong>Critical step after setup on the second/third device:</strong> LiveSync won’t automatically pull your vault from the server. You need to explicitly tell it to fetch:</p><ol><li>Go to <strong>Settings → Self-hosted LiveSync</strong></li><li>Find <strong>“Rebuild everything”</strong></li><li>Choose <strong>“Fetch from remote”</strong> - this pulls your entire vault from CouchDB</li></ol><p><strong>Do NOT choose “Send to remote”</strong> - that would push your empty vault and overwrite everything on the server.</p><p>The initial fetch takes a few minutes depending on vault size. After that, sync is real-time.</p><h3>Step 10 - Enable LiveSync mode</h3><p>On each device, go to LiveSync settings → <strong>Sync Settings</strong>:</p><ul><li>Set <strong>Sync Mode</strong> to <strong>“LiveSync”</strong></li></ul><p>This enables real-time sync via CouchDB’s _changes feed. Edits appear on other devices within 1–2 seconds.</p><p>Alternatives:</p><ul><li><strong>Periodic</strong> - polls every N seconds. Uses less battery on mobile.</li><li><strong>On Events</strong> - syncs only on file open/save/close. Most conservative.</li></ul><h3>Part 5: Multiple Vaults</h3><p>Each vault gets its own CouchDB database. Generate a new Setup URI with a different database name for each vault:</p><pre>export hostname=https://&lt;your-machine&gt;.&lt;your-tailnet&gt;.ts.net<br>export database=work-notes          # different database name<br>export passphrase=&lt;YOUR_E2EE_PASSPHRASE&gt;<br>export username=obsidian<br>export password=&lt;YOUR_STRONG_PASSWORD&gt;</pre><pre>deno run -A <a href="https://raw.githubusercontent.com/vrtmrz/obsidian-livesync/main/utils/flyio/generate_setupuri.ts">https://raw.githubusercontent.com/vrtmrz/obsidian-livesync/main/utils/flyio/generate_setupuri.ts</a></pre><p>Then open that vault in Obsidian, install LiveSync, and paste this new URI. The plugin configuration is per-vault, so each vault connects to its own database independently.</p><p>All vaults share the same CouchDB instance and Tailscale endpoint — only the database name differs.</p><h3>Part 6: Maintenance and Troubleshooting</h3><h3>Verify everything works</h3><ul><li>Edit a note on Mac → should appear on iPhone within 1–2 seconds</li><li>Create a new note on iPad → should sync to Mac and iPhone</li><li>Edit the same note on two devices simultaneously → non-overlapping edits auto-merge, overlapping edits trigger the conflict resolver</li></ul><h3>Useful commands</h3><pre># Check CouchDB status<br>curl http://127.0.0.1:5984/ -u obsidian:&lt;YOUR_STRONG_PASSWORD&gt;</pre><pre># Check Tailscale serve<br>tailscale serve status</pre><pre># View CouchDB logs<br>cd ~/obsidian-livesync &amp;&amp; docker compose logs -f couchdb</pre><pre># Access CouchDB admin panel (Fauxton)<br># Open in browser: https://&lt;your-machine&gt;.&lt;your-tailnet&gt;.ts.net/_utils/</pre><pre># Restart CouchDB<br>cd ~/obsidian-livesync &amp;&amp; docker compose restart</pre><pre># Check database size<br>curl -s <a href="http://127.0.0.1:5984/obsidiannotes">http://127.0.0.1:5984/obsidiannotes</a> -u obsidian:&lt;YOUR_STRONG_PASSWORD&gt; | python3 -m json.tool</pre><h3>Common issues</h3><p><strong>“Could not fetch configuration from remote”</strong> Usually a CORS issue. Verify:</p><pre>curl -s http://localhost:5984/_node/_local/_config/chttpd/enable_cors \<br>  -u obsidian:&lt;YOUR_STRONG_PASSWORD&gt;<br># Should return &quot;true&quot;</pre><pre>curl -s <a href="http://localhost:5984/_node/_local/_config/cors/origins">http://localhost:5984/_node/_local/_config/cors/origins</a> \<br>  -u obsidian:&lt;YOUR_STRONG_PASSWORD&gt;<br># Should return &quot;app://obsidian.md,capacitor://localhost,http://localhost&quot;</pre><p>If not, re-run the init script from Step 4.</p><p><strong>“Unable to retrieve remote milestones” on a fresh device</strong> Normal. The database is empty. Choose “Rebuild everything → Send to remote” on your first device, or “Fetch from remote” on subsequent devices.</p><p><strong>Notes not appearing on iOS after setup</strong> You need to explicitly pull via “Rebuild everything → Fetch from remote.” LiveSync won’t auto-pull on a new device because it can’t distinguish “new device that should receive notes” from “device with a different vault that shouldn’t be overwritten.”</p><p><strong>Connection timeout on mobile</strong> Ensure Tailscale is connected on the device. Check tailscale status on your server to verify the device appears online.</p><p><strong>Permission errors on couchdb-data</strong> CouchDB runs as UID 5984:</p><pre>sudo chown -R 5984:5984 ~/obsidian-livesync/couchdb-data ~/obsidian-livesync/couchdb-etc</pre><h3>Backup strategy</h3><p>Your notes exist in three places: local vaults on each device and the CouchDB database. For extra safety:</p><pre># Add to crontab (crontab -e) — daily backup at 3 AM<br>0 3 * * * cd ~/obsidian-livesync &amp;&amp; docker compose exec -T couchdb \<br>  curl -s -u obsidian:&lt;YOUR_PASSWORD&gt; \<br>  http://localhost:5984/obsidiannotes/_all_docs?include_docs=true \<br>  &gt; backups/backup-$(date +\%Y\%m\%d).json</pre><p>You can also keep Git as a version history layer - periodic commits from your Mac’s vault folder. Just don’t use Git as a sync mechanism.</p><h3>The Architecture at a Glance</h3><pre>┌─────────────────────────────────────────────────────┐<br>│ Linux Server                                        │<br>│                                                     │<br>│  Docker: couchdb:latest                             │<br>│    └── Listening on 127.0.0.1:5984 (localhost only) │<br>│    └── CORS configured for Obsidian origins         │<br>│    └── Auth required (no anonymous access)          │<br>│    └── Data persisted in ~/obsidian-livesync/       │<br>│                                                     │<br>│  Tailscale daemon                                   │<br>│    └── HTTPS :443 → localhost:5984                  │<br>│    └── Auto-renewed Let&#39;s Encrypt cert              │<br>│    └── Tailnet-only (not internet-exposed)          │<br>└─────────────────────────────────────────────────────┘<br>         ▲              ▲              ▲<br>         │  WireGuard   │   encrypted  │<br>    ┌────┘   tunnels    │              └────┐<br>    │                   │                   │<br>┌───┴───┐          ┌────┴──┐          ┌─────┴─┐<br>│  Mac  │          │iPhone │          │ iPad  │<br>│PouchDB│◄────────►│PouchDB│◄────────►│PouchDB│<br>│   ↕   │          │   ↕   │          │   ↕   │<br>│ Vault │          │ Vault │          │ Vault │<br>│(files)│          │(files)│          │(files)│<br>└───────┘          └───────┘          └───────┘</pre><p>Every device syncs independently with CouchDB. Your Mac doesn’t need to be online for your iPhone to get the latest notes - the server is the always-on hub. Tailscale encrypts everything in transit. E2EE encrypts everything at rest on the server. If any component goes down, every device still has a complete local copy of your vault and resumes syncing automatically when connectivity is restored.</p><p>And your notes are always just Markdown files on disk. If LiveSync, CouchDB, or your entire server disappears tomorrow, you open your vault folder and everything is there. No proprietary formats, no export needed.</p><h3>Final Thoughts</h3><p>The setup takes under an hour. After that, you genuinely don’t think about sync anymore - it just works. Edit a note on your Mac, pick up your phone, and it’s there. Open the same note on two devices, edit different sections, and they merge cleanly. It’s what Obsidian Sync does, but free, self-hosted, and end-to-end encrypted on your own infrastructure.</p><p>The only maintenance I’ve done in months is the occasional docker compose pull &amp;&amp; docker compose up -d to update CouchDB. Everything else runs silently.</p><p>If you’re already running a home server, this is one of the most immediately useful things you can put on it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d2f1aaa1f62" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Fixed YouTube Getting Blocked by My Office VPN Using a Home Server SOCKS Proxy]]></title>
            <link>https://medium.com/@abhirajsinghtomar/how-i-fixed-youtube-getting-blocked-by-my-office-vpn-using-a-home-server-socks-proxy-289f6dde45c2?source=rss-9bcf1f03e405------2</link>
            <guid isPermaLink="false">https://medium.com/p/289f6dde45c2</guid>
            <category><![CDATA[home-server]]></category>
            <category><![CDATA[proxy]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[proxy-server]]></category>
            <category><![CDATA[corporate-vpn]]></category>
            <dc:creator><![CDATA[abhiraj singh tomar]]></dc:creator>
            <pubDate>Sun, 22 Mar 2026 19:58:57 GMT</pubDate>
            <atom:updated>2026-03-22T19:58:57.116Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="How I Built a Self-Hosted SOCKS5 Proxy to Bypass Corporate VPN Restrictions" src="https://cdn-images-1.medium.com/max/1024/1*1LFPqMHsgyA2nayzPJt_dA.png" /></figure><p><em>A practical guide to routing personal browser traffic through your own server as SOCKS proxy.</em></p><h3>The Problem</h3><p>If you work with a corporate VPN, you’ve probably hit this at some point. The moment you connect to the office VPN, everything routes through it - including your personal YouTube, Gmail, and Netflix. Some companies block streaming sites outright. Others just throttle them. Either way, you’re stuck.</p><p>For me it was YouTube. The moment my office VPN came on, YouTube would refuse to load. Switching back and forth between VPN on and off every time I wanted to watch something was getting old fast. In fact I could not even listen to music while accessing some internal office resource protected behind VPN.</p><p>The obvious solution is split tunneling - configuring the VPN to only route work traffic through the corporate network and leave everything else alone. Most corporate VPN clients don’t give you that option. It’s locked down by IT policy, and asking IT to whitelist YouTube feels like a losing argument.</p><p>So I solved it myself.</p><h3>The Solution: A SOCKS Proxy via My Home Server</h3><p>I already had a home server running Ubuntu server- I’d set it up for self-hosting various tools. It sat at home connected to my regular home internet, completely independent of my office VPN.</p><p>The idea is simple: instead of routing personal browser traffic through the office VPN, route it through your home server instead. A SOCKS proxy is perfect for this - it’s a lightweight tunnel that tells your browser “send all your traffic here first, then out to the internet.”</p><p>The result is that YouTube, Gmail, and personal browsing all appear to come from my home IP, completely bypassing the office VPN’s restrictions. Work traffic still goes through the corporate VPN as normal. The two are completely separate.</p><p>Here’s exactly how I set it up.</p><h3>Prerequisites</h3><ul><li>A home server (I’m running Ubuntu Server) accessible via Tailscale</li><li>SSH access to the server with key-based authentication</li><li>Office machine (this guide covers the Mac side-Linux/Windows would use different startup methods)</li></ul><h3>Step 1: Create the SOCKS Proxy</h3><p>A SOCKS5 proxy over SSH requires exactly one command. SSH has this built in - no extra software needed on either end:</p><pre>ssh -N -D 1080 -p 2222 -I ~/.ssh/homeserver_ed25519 server@IP</pre><p>Breaking this down:</p><ul><li>-N : don&#39;t execute any remote command, just hold the connection open</li><li>-D 1080 : create a dynamic SOCKS proxy on local port 1080</li><li>-p 2222 : connect on port 2222 (my custom SSH port)</li><li>-I ~/.ssh/homeserver_ed25519 : identity key used for authentication</li><li>server@homeserver : my username and server hostname via Tailscale Magic DNS</li></ul><p>Once this command is running, you have a SOCKS5 proxy listening on localhost:1080 on your Mac. Any application you point at that address will have its traffic routed through your home server.</p><h3>Step 2: Configure Firefox to Use the Proxy</h3><p>The key insight here is that you don’t want ALL traffic going through the proxy, just your personal browser (I use Firefox for all my personal logins and chrome for office work). Firefox lets you configure a proxy independently of your system settings, which is exactly what we need.<br><strong>Note:</strong> you can use any browser, it my require you to add a browser extension if proxy is not supported by the browser natively.</p><ol><li>Open Firefox → Settings (or about:preferences)</li><li>Scroll to the bottom → <strong>Network Settings</strong> → click <strong>Settings…</strong></li><li>Select <strong>Manual proxy configuration</strong></li><li>Leave HTTP Proxy and SSL Proxy blank</li><li>Set <strong>SOCKS Host</strong>: 127.0.0.1, <strong>Port</strong>: 1080</li><li>Select <strong>SOCKS v5</strong></li><li>Check <strong>Proxy DNS when using SOCKS v5</strong>, this routes DNS queries through the proxy too, which prevents DNS leaks</li><li>Click OK</li></ol><p>Now Firefox routes all traffic through your home server. Chrome, Safari, and other apps continue using your normal connection (office VPN). YouTube works again in Firefox. Work tools in Chrome remain on the corporate VPN.</p><h3>Step 3: Handle the SSH Passphrase Automatically</h3><p>The issue with setup is that every time you restart your Mac or the SSH connection drops, you have to manually run the SSH command again and enter your passphrase.</p><p>The fix is two parts: store the passphrase in macOS Keychain, and then create a launchd service to keep the proxy running automatically.</p><h3>Add Your Key to macOS Keychain</h3><pre>ssh-add --apple-use-keychain ~/.ssh/homeserver_ed25519</pre><p>Enter your passphrase once. macOS stores it securely in Keychain - you’ll never be prompted again.</p><p>Make sure your ~/.ssh/config is configured to use the Keychain:</p><pre>Host homeserver<br>    HostName 100.x.x.x<br>    User server<br>    Port 2222<br>    IdentityFile ~/.ssh/homeserver_ed25519<br>    IdentitiesOnly yes<br>    AddKeysToAgent yes<br>    UseKeychain yes</pre><p>The UseKeychain yes line is the important one - it tells SSH to look in Keychain for the passphrase automatically.</p><h3>Create a launchd Service</h3><p>macOS uses launchd to manage background services - it&#39;s the equivalent of systemd on Linux. We&#39;ll create a service that starts the SOCKS proxy on login and automatically restarts it if the connection ever drops.</p><p>Create the service file:</p><pre>vim ~/Library/LaunchAgents/com.homeserver.socks.plist</pre><p>Paste this content:</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot;<br>  &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;<br>&lt;plist version=&quot;1.0&quot;&gt;<br>&lt;dict&gt;<br>    &lt;key&gt;Label&lt;/key&gt;<br>    &lt;string&gt;com.homeserver.socks&lt;/string&gt;<br>&lt;key&gt;ProgramArguments&lt;/key&gt;<br>    &lt;array&gt;<br>        &lt;string&gt;/usr/bin/ssh&lt;/string&gt;<br>        &lt;string&gt;-N&lt;/string&gt;<br>        &lt;string&gt;-D&lt;/string&gt;<br>        &lt;string&gt;1080&lt;/string&gt;<br>        &lt;string&gt;-o&lt;/string&gt;<br>        &lt;string&gt;ExitOnForwardFailure=yes&lt;/string&gt;<br>        &lt;string&gt;-o&lt;/string&gt;<br>        &lt;string&gt;ServerAliveInterval=30&lt;/string&gt;<br>        &lt;string&gt;-o&lt;/string&gt;<br>        &lt;string&gt;ServerAliveCountMax=3&lt;/string&gt;<br>        &lt;string&gt;homeserver&lt;/string&gt;<br>    &lt;/array&gt;<br>    &lt;key&gt;RunAtLoad&lt;/key&gt;<br>    &lt;true/&gt;<br>    &lt;key&gt;KeepAlive&lt;/key&gt;<br>    &lt;true/&gt;<br>    &lt;key&gt;RestartThrottle&lt;/key&gt;<br>    &lt;integer&gt;10&lt;/integer&gt;<br>    &lt;key&gt;StandardOutPath&lt;/key&gt;<br>    &lt;string&gt;/tmp/socks-proxy.log&lt;/string&gt;<br>    &lt;key&gt;StandardErrorPath&lt;/key&gt;<br>    &lt;string&gt;/tmp/socks-proxy-error.log&lt;/string&gt;<br>&lt;/dict&gt;<br>&lt;/plist&gt;</pre><p>A few things worth noting in this config:</p><ul><li>RunAtLoad: true:starts the proxy as soon as you log in to your Mac</li><li>KeepAlive: true : if the SSH process exits for any reason, launchd restarts it immediately</li><li>RestartThrottle: 10 : waits 10 seconds between restart attempts so it doesn&#39;t spam connection attempts if the server is unreachable</li><li>ServerAliveInterval=30 : SSH sends a keepalive packet every 30 seconds so the connection doesn&#39;t silently timeout on idle</li><li>ServerAliveCountMax=3 : if 3 consecutive keepalives fail (90 seconds), SSH exits cleanly, and launchd restarts it</li></ul><p>Load and start the service:</p><pre>launchctl load ~/Library/LaunchAgents/com.homeserver.socks.plist<br>launchctl start com.homeserver.socks</pre><h3>Verify It’s Working</h3><pre># Check the service is running (should show a PID)<br>launchctl list | grep homeserver</pre><pre># Test the proxy — should return your home server&#39;s public IP, not your office IP<br>curl --socks5 localhost:1080 <a href="https://ifconfig.me/">https://ifconfig.me</a></pre><p>If the IP that comes back matches your home internet connection, it’s working.</p><h3>Day-to-Day Experience</h3><p>Once this is set up, you don’t think about it again. Your Mac boots, logs in, and within seconds the SOCKS proxy is running in the background. Firefox uses it automatically. YouTube, personal Gmail, and everything else in Firefox route through your home connection. Everything in Chrome stays on the office VPN.</p><p>If your home server goes offline temporarily, launchd keeps retrying every 10 seconds. When the server comes back, the proxy re-establishes automatically.</p><p>You can manage the service with these commands if you ever need to:</p><pre># Stop the proxy<br>launchctl stop com.homeserver.socks<br><br># Start it again<br>launchctl start com.homeserver.socks<br><br># Disable it permanently (won&#39;t start on login)<br>launchctl unload ~/Library/LaunchAgents/com.homeserver.socks.plist<br><br># Check logs if something seems wrong<br>cat /tmp/socks-proxy-error.log</pre><h3>A Note on Privacy and Security</h3><p>Routing browser traffic through your own home server is about as private as it gets. The traffic goes:</p><pre>Firefox → encrypted SSH tunnel → your home server → internet</pre><p>Nobody on your office network can see what Firefox is doing. The office VPN never touches that traffic. Your home ISP sees encrypted SSH traffic going to your server’s IP - not the sites you’re visiting, because the SSH tunnel handles that.</p><p>This is meaningfully different from a commercial VPN service where you’re trusting a third party with your traffic. Your home server is infrastructure you own and control.</p><h3>Wrapping Up</h3><p>The whole setup takes about 15 minutes and the result is a fully automated, zero-maintenance solution. The only ongoing cost is the home server itself - which in my case is already running for other reasons.</p><p>You can use a free tier instance provided cloud providers like Oracle, AWS, fly.io, etc if you don’t have a home server.</p><p>If you’re hitting the same problem - corporate VPN blocking or throttling personal browsing - this is a cleaner fix than anything involving IT tickets or VPN client workarounds. You own the solution, you understand exactly how it works, and it survives reboots without any manual intervention.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=289f6dde45c2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>