236 lines
32 KiB
HTML
236 lines
32 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<link href="/css/style.css" rel="stylesheet" />
|
|
|
|
<title>Setup dns with adblock and dot/doh with pi-hole and unbound</title>
|
|
<meta property="og:title" content="Setup dns with adblock and dot/doh with pi-hole and unbound" />
|
|
<meta property="og:description" content="Just another day I seted up my own private dns server that has adblocking ( and other stuff ) using pihole and uses unbound as a resolver. To safelly connect to the dns server I’m using DNS over HTTPS for my browser’s and HTTPS over TLS for stuffy for my whole desktop and private dns in android ( Android has DoH support but only for google and cloudflare right now). Let’s get on to setting everything up" />
|
|
<meta property="og:type" content="article" />
|
|
<meta property="og:url" content="https://cronyakatsuki.xyz/blog/setup-dns-pihole-unbound/" /><meta property="article:section" content="blog" />
|
|
<meta property="article:published_time" content="2023-09-27T00:00:00+00:00" />
|
|
<meta property="article:modified_time" content="2023-09-27T00:00:00+00:00" /><meta property="og:site_name" content="Crony Akatsuki's Website" />
|
|
|
|
</head>
|
|
|
|
<body>
|
|
<header>
|
|
<h1>Crony Akatsuki</h1>
|
|
<nav>
|
|
<span><a href="/">Home</a></span>
|
|
<span>|</span>
|
|
<span><a href="/about">About</a></span>
|
|
<span>|</span>
|
|
<span><a href="/blog">Blog</a></span>
|
|
<span>|</span>
|
|
<span><a href="/services">Services</a></span>
|
|
</nav>
|
|
</header>
|
|
|
|
|
|
<main>
|
|
<div id="content">
|
|
|
|
<h1>Setup dns with adblock and dot/doh with pi-hole and unbound</h1>
|
|
|
|
|
|
|
|
<div id="date">
|
|
<p>27-09-2023</p>
|
|
</div>
|
|
|
|
<p>Just another day I seted up my own private dns server that has adblocking ( and other stuff ) using pihole and uses unbound as a resolver. To safelly connect to the dns server I’m using DNS over HTTPS for my browser’s and HTTPS over TLS for stuffy for my whole desktop and private dns in android ( Android has DoH support but only for google and cloudflare right now). Let’s get on to setting everything up</p>
|
|
<!-- raw HTML omitted -->
|
|
<h2 id="1-pihole">1. Pihole</h2>
|
|
<p>Let’s start with setting up pihole. I will be installing it with their script on a debian system for easier unbound integration ( unbound doesn’t have an official docker container ).</p>
|
|
<p>I recommend to read up on the pihole’s docs on exactly how to install it since pihole get’s frequent updates. <a href="https://docs.pi-hole.net/main/basic-install/">DOCS</a></p>
|
|
<p>I recommend you to install the admin page for easier managmenet and ability to change the upstream dns server ( needed for changing it to unbound later on ). To be able to access the admin page I use an nginx configuration like this one.</p>
|
|
<div class="highlight"><pre tabindex="0" style="color:#ef9f76;background-color:#303446;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-nginx" data-lang="nginx"><span style="display:flex;"><span><span style="color:#ca9ee6">server</span> <span style="color:#c6d0f5">{</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">server_name</span> <span style="color:#a6d189">example.com</span> <span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">location</span> <span style="color:#a6d189">/</span> <span style="color:#c6d0f5">{</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">return</span> 403<span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#c6d0f5">}</span>
|
|
</span></span><span style="display:flex;"><span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">location</span> <span style="color:#a6d189">/admin</span> <span style="color:#c6d0f5">{</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">proxy_pass</span> <span style="color:#a6d189">http://127.0.0.1:8185/admin</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">proxy_set_header</span> <span style="color:#a6d189">Host</span> <span style="color:#babbf1">$host</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#c6d0f5">}</span>
|
|
</span></span><span style="display:flex;"><span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#626880;font-style:italic"># If you want to log user activity, comment these
|
|
</span></span></span><span style="display:flex;"><span><span style="color:#626880;font-style:italic"></span> <span style="color:#ca9ee6">access_log</span> <span style="color:#a6d189">/dev/null</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">error_log</span> <span style="color:#a6d189">/dev/null</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">listen</span> <span style="color:#a6d189">[::]:443</span> <span style="color:#a6d189">ssl</span><span style="color:#c6d0f5">;</span> <span style="color:#626880;font-style:italic"># managed by Certbot
|
|
</span></span></span><span style="display:flex;"><span><span style="color:#626880;font-style:italic"></span> <span style="color:#ca9ee6">listen</span> 443 <span style="color:#a6d189">ssl</span><span style="color:#c6d0f5">;</span> <span style="color:#626880;font-style:italic"># managed by Certbot
|
|
</span></span></span><span style="display:flex;"><span><span style="color:#626880;font-style:italic"></span> <span style="color:#ca9ee6">ssl_certificate</span> <span style="color:#a6d189">/etc/letsencrypt/live/example.com/fullchain.pem</span><span style="color:#c6d0f5">;</span> <span style="color:#626880;font-style:italic"># managed by Certbot
|
|
</span></span></span><span style="display:flex;"><span><span style="color:#626880;font-style:italic"></span> <span style="color:#ca9ee6">ssl_certificate_key</span> <span style="color:#a6d189">/etc/letsencrypt/live/example.com/privkey.pem</span><span style="color:#c6d0f5">;</span> <span style="color:#626880;font-style:italic"># managed by Certbot
|
|
</span></span></span><span style="display:flex;"><span><span style="color:#626880;font-style:italic"></span> <span style="color:#ca9ee6">include</span> <span style="color:#a6d189">/etc/letsencrypt/options-ssl-nginx.conf</span><span style="color:#c6d0f5">;</span> <span style="color:#626880;font-style:italic"># managed by Certbot
|
|
</span></span></span><span style="display:flex;"><span><span style="color:#626880;font-style:italic"></span> <span style="color:#ca9ee6">ssl_dhparam</span> <span style="color:#a6d189">/etc/letsencrypt/ssl-dhparams.pem</span><span style="color:#c6d0f5">;</span> <span style="color:#626880;font-style:italic"># managed by Certbot
|
|
</span></span></span><span style="display:flex;"><span><span style="color:#626880;font-style:italic"></span><span style="color:#c6d0f5">}</span>
|
|
</span></span><span style="display:flex;"><span><span style="color:#ca9ee6">server</span> <span style="color:#c6d0f5">{</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">if</span> <span style="color:#a6d189">(</span><span style="color:#babbf1">$host</span> <span style="color:#c6d0f5">=</span> <span style="color:#a6d189">example.com)</span> <span style="color:#c6d0f5">{</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">return</span> 301 <span style="color:#a6d189">https://</span><span style="color:#babbf1">$host$request_uri</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#c6d0f5">}</span> <span style="color:#626880;font-style:italic"># managed by Certbot
|
|
</span></span></span><span style="display:flex;"><span><span style="color:#626880;font-style:italic"></span>
|
|
</span></span><span style="display:flex;"><span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">server_name</span> <span style="color:#a6d189">example.com</span> <span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">listen</span> 80<span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">listen</span> <span style="color:#a6d189">[::]:80</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">return</span> 404<span style="color:#c6d0f5">;</span> <span style="color:#626880;font-style:italic"># managed by Certbot
|
|
</span></span></span><span style="display:flex;"><span><span style="color:#626880;font-style:italic"></span><span style="color:#c6d0f5">}</span>
|
|
</span></span></code></pre></div><p>The main point of this config is the <code>/admin</code> location that you need to pass the lighttpd port to acces the website, you can just do it on your main website also.
|
|
Also to make lighttpd work with nginx listening on port 80 you need to edit the <code>server.port</code> to port you wan’t to use in lighttpd config file located at <code>/etc/lighttpd/lighttpd.conf</code> and then just restart lighttpd</p>
|
|
<h2 id="2-unbound">2. Unbound</h2>
|
|
<p>For this part I will just link the pi-hole’s unbound documentation because it is the most correct one and updated as things change regulary.
|
|
<a href="https://docs.pi-hole.net/guides/dns/unbound/">Pi-hole unbound docs</a></p>
|
|
<h2 id="3-dns-over-tls">3. DNS over TLS</h2>
|
|
<p>For dns over tls you need to first have a ssl certificate. I recommend on using certbot to generate one with this command <code>certbot --nginx -d dot.example.com</code>.</p>
|
|
<p>Next you will need a reverse proxy, in my case I use nginx. You will need to add this configuration to your main nginx config located at <code>/etc/nginx/nginx.conf</code>. <strong>Make sure to add this outside of the http block and change example.com to your domain</strong></p>
|
|
<div class="highlight"><pre tabindex="0" style="color:#ef9f76;background-color:#303446;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-nginx" data-lang="nginx"><span style="display:flex;"><span><span style="color:#ca9ee6">stream</span> <span style="color:#c6d0f5">{</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">log_format</span> <span style="color:#a6d189">basic</span> <span style="color:#a6d189">'</span><span style="color:#babbf1">$remote_addr</span> <span style="color:#a6d189">[</span><span style="color:#babbf1">$time_local]</span> <span style="color:#babbf1">$protocol</span> <span style="color:#babbf1">$status</span> <span style="color:#babbf1">$bytes_sent</span> <span style="color:#babbf1">$bytes_received</span> <span style="color:#babbf1">$session_time</span> <span style="color:#babbf1">$upstream_addr'</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">upstream</span> <span style="color:#a6d189">dns</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#c6d0f5">{</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">zone</span> <span style="color:#a6d189">dns</span> 64k<span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">server</span> <span style="color:#babbf1">127.0.0.1</span><span style="color:#c6d0f5">:</span>53<span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#c6d0f5">}</span>
|
|
</span></span><span style="display:flex;"><span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">server</span> <span style="color:#c6d0f5">{</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">listen</span> 853 <span style="color:#a6d189">ssl</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">access_log</span> <span style="color:#a6d189">/var/log/nginx/dot-access.log</span> <span style="color:#a6d189">basic</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">error_log</span> <span style="color:#a6d189">/var/log/nginx/dot-error.log</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">ssl_certificate</span> <span style="color:#a6d189">/etc/letsencrypt/live/dot.example.com/fullchain.pem</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">ssl_certificate_key</span> <span style="color:#a6d189">/etc/letsencrypt/live/dot.example.com/privkey.pem</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">ssl_protocols</span> <span style="color:#a6d189">TLSv1.2</span> <span style="color:#a6d189">TLSv1.3</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">ssl_ciphers</span> <span style="color:#a6d189">HIGH:!aNULL:!MD5</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">ssl_handshake_timeout</span> <span style="color:#a6d189">10s</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">ssl_session_cache</span> <span style="color:#a6d189">shared:SSL:20m</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">ssl_session_timeout</span> <span style="color:#a6d189">4h</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">proxy_pass</span> <span style="color:#a6d189">dns</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">proxy_responses</span> 1<span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">proxy_timeout</span> <span style="color:#a6d189">1s</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#c6d0f5">}</span>
|
|
</span></span><span style="display:flex;"><span><span style="color:#c6d0f5">}</span>
|
|
</span></span></code></pre></div><p>Also make sure to enable port 853, example ufw command is <code>ufw allow 853/tcp</code>. Then restart nginx, to test if this configuration is working you can use your android phone by setting the private dns address to <code>dot.example.com</code> and then visit the website<a href="https://dnsleaktest.com">dnsleaktest</a></p>
|
|
<h2 id="4-dns-over-https">4. DNS over HTTPS</h2>
|
|
<p>For using dns over https we will be installing additional package called dnsdinst. On debian systems just run <code>apt install dnsdinst</code>. Next you will need to setup dnsdinst config and restart it. Make sure to change example.com.</p>
|
|
<div class="highlight"><pre tabindex="0" style="color:#ef9f76;background-color:#303446;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-conf" data-lang="conf"><span style="display:flex;"><span><span style="color:#babbf1">--</span> <span style="color:#babbf1">dnsdist</span> <span style="color:#babbf1">configuration</span> <span style="color:#babbf1">file</span><span style="color:#c6d0f5">,</span> <span style="color:#babbf1">an</span> <span style="color:#babbf1">example</span> <span style="color:#babbf1">can</span> <span style="color:#babbf1">be</span> <span style="color:#babbf1">found</span> <span style="color:#babbf1">in</span> <span style="color:#e78284">/</span><span style="color:#babbf1">usr</span><span style="color:#e78284">/</span><span style="color:#babbf1">share</span><span style="color:#e78284">/</span><span style="color:#babbf1">doc</span><span style="color:#e78284">/</span><span style="color:#babbf1">dnsdist</span><span style="color:#e78284">/</span><span style="color:#babbf1">examples</span><span style="color:#e78284">/</span>
|
|
</span></span><span style="display:flex;"><span>
|
|
</span></span><span style="display:flex;"><span><span style="color:#babbf1">--</span> <span style="color:#babbf1">disable</span> <span style="color:#babbf1">security</span> <span style="color:#babbf1">status</span> <span style="color:#babbf1">polling</span> <span style="color:#babbf1">via</span> <span style="color:#babbf1">DNS</span>
|
|
</span></span><span style="display:flex;"><span><span style="color:#99d1db">setSecurityPollSuffix</span><span style="color:#c6d0f5">(</span><span style="color:#a6d189">""</span><span style="color:#c6d0f5">)</span>
|
|
</span></span><span style="display:flex;"><span>
|
|
</span></span><span style="display:flex;"><span><span style="color:#babbf1">--</span> <span style="color:#babbf1">fix</span> <span style="color:#babbf1">up</span> <span style="color:#babbf1">possibly</span> <span style="color:#babbf1">badly</span> <span style="color:#babbf1">truncated</span> <span style="color:#babbf1">answers</span> <span style="color:#babbf1">from</span> <span style="color:#babbf1">pdns</span> <span style="color:#babbf1">2.9.22</span>
|
|
</span></span><span style="display:flex;"><span><span style="color:#babbf1">--</span> <span style="color:#99d1db">truncateTC</span><span style="color:#c6d0f5">(</span><span style="color:#ca9ee6;font-style:italic">true</span><span style="color:#c6d0f5">)</span>
|
|
</span></span><span style="display:flex;"><span>
|
|
</span></span><span style="display:flex;"><span><span style="color:#babbf1">--</span> <span style="color:#babbf1">Answer</span> <span style="color:#babbf1">to</span> <span style="color:#babbf1">only</span> <span style="color:#babbf1">clients</span> <span style="color:#babbf1">from</span> <span style="color:#babbf1">this</span> <span style="color:#e5c890">subnet</span>
|
|
</span></span><span style="display:flex;"><span><span style="color:#99d1db">setACL</span><span style="color:#c6d0f5">(</span><span style="color:#a6d189">"127.0.0.1/8"</span><span style="color:#c6d0f5">)</span>
|
|
</span></span><span style="display:flex;"><span>
|
|
</span></span><span style="display:flex;"><span><span style="color:#babbf1">--</span> <span style="color:#babbf1">Define</span> <span style="color:#babbf1">upstream</span> <span style="color:#babbf1">DNS</span> <span style="color:#99d1db">server</span> <span style="color:#c6d0f5">(</span><span style="color:#babbf1">Pi-hole</span><span style="color:#c6d0f5">)</span>
|
|
</span></span><span style="display:flex;"><span><span style="color:#99d1db">newServer</span><span style="color:#c6d0f5">({</span><span style="color:#babbf1">address</span><span style="color:#99d1db">=</span><span style="color:#a6d189">"127.0.0.1"</span><span style="color:#c6d0f5">,</span> <span style="color:#babbf1">name</span><span style="color:#99d1db">=</span><span style="color:#a6d189">"Pi-hole"</span><span style="color:#c6d0f5">,</span> <span style="color:#babbf1">checkName</span><span style="color:#99d1db">=</span><span style="color:#a6d189">"example.com"</span><span style="color:#c6d0f5">,</span> <span style="color:#babbf1">checkInterval</span><span style="color:#99d1db">=</span><span style="color:#babbf1">60</span><span style="color:#c6d0f5">,</span> <span style="color:#babbf1">mustResolve</span><span style="color:#99d1db">=</span><span style="color:#ca9ee6;font-style:italic">true</span><span style="color:#c6d0f5">})</span>
|
|
</span></span><span style="display:flex;"><span>
|
|
</span></span><span style="display:flex;"><span><span style="color:#babbf1">--</span> <span style="color:#babbf1">Create</span> <span style="color:#babbf1">local</span> <span style="color:#babbf1">DOH</span> <span style="color:#babbf1">server</span> <span style="color:#babbf1">listener</span> <span style="color:#babbf1">in</span> <span style="color:#babbf1">DNS</span> <span style="color:#babbf1">over</span> <span style="color:#babbf1">HTTP</span> <span style="color:#babbf1">mode</span><span style="color:#c6d0f5">,</span> <span style="color:#babbf1">otherwise</span> <span style="color:#babbf1">the</span> <span style="color:#babbf1">information</span> <span style="color:#babbf1">coming</span> <span style="color:#babbf1">from</span> <span style="color:#babbf1">nginx</span> <span style="color:#babbf1">won</span><span style="color:#e78284">'</span><span style="color:#babbf1">t</span> <span style="color:#babbf1">be</span> <span style="color:#babbf1">processed</span> <span style="color:#babbf1">well</span>
|
|
</span></span><span style="display:flex;"><span><span style="color:#99d1db">addDOHLocal</span><span style="color:#c6d0f5">(</span><span style="color:#a6d189">"127.0.0.1:5300"</span><span style="color:#c6d0f5">,</span> <span style="color:#babbf1">nil</span><span style="color:#c6d0f5">,</span> <span style="color:#babbf1">nil</span><span style="color:#c6d0f5">,</span> <span style="color:#a6d189">"/dns-query"</span><span style="color:#c6d0f5">,</span> <span style="color:#c6d0f5">{</span> <span style="color:#babbf1">reusePort</span><span style="color:#99d1db">=</span><span style="color:#ca9ee6;font-style:italic">true</span> <span style="color:#c6d0f5">})</span>
|
|
</span></span></code></pre></div><p>Next we will need another ssl certificate for the doh domain, for that we will once again using certbot with this command <code>certbot --nginx -d doh.example.com</code>after that add this configuratin to nginx either in sites-available and linking it to sites enabled or in http block in main nginx configuration.</p>
|
|
<div class="highlight"><pre tabindex="0" style="color:#ef9f76;background-color:#303446;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-nginx" data-lang="nginx"><span style="display:flex;"><span><span style="color:#626880;font-style:italic"># Proxy Cache storage - so we can cache the DoH response from the upstream
|
|
</span></span></span><span style="display:flex;"><span><span style="color:#626880;font-style:italic"></span><span style="color:#ca9ee6">proxy_cache_path</span> <span style="color:#a6d189">/var/run/doh_cache</span> <span style="color:#a6d189">levels=1:2</span> <span style="color:#a6d189">keys_zone=doh_cache:10m</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span>
|
|
</span></span><span style="display:flex;"><span><span style="color:#ca9ee6">server</span> <span style="color:#c6d0f5">{</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">listen</span> 80<span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">server_name</span> <span style="color:#a6d189">doh.example.com</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">return</span> 301 <span style="color:#a6d189">https://doh.example.com/</span><span style="color:#babbf1">$request_uri</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span><span style="color:#c6d0f5">}</span>
|
|
</span></span><span style="display:flex;"><span>
|
|
</span></span><span style="display:flex;"><span><span style="color:#626880;font-style:italic"># This virtual server accepts HTTP/2 over HTTPS
|
|
</span></span></span><span style="display:flex;"><span><span style="color:#626880;font-style:italic"></span><span style="color:#ca9ee6">server</span> <span style="color:#c6d0f5">{</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">listen</span> 443 <span style="color:#a6d189">ssl</span> <span style="color:#a6d189">http2</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">server_name</span> <span style="color:#a6d189">doh.example.com</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">access_log</span> <span style="color:#a6d189">/var/log/nginx/doh.access</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">error_log</span> <span style="color:#a6d189">/var/log/nginx/doh.error</span> <span style="color:#a6d189">error</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">ssl_certificate</span> <span style="color:#a6d189">/etc/letsencrypt/live/doh.example.com/fullchain.pem</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">ssl_certificate_key</span> <span style="color:#a6d189">/etc/letsencrypt/live/doh.example.com/privkey.pem</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span>
|
|
</span></span><span style="display:flex;"><span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#626880;font-style:italic"># DoH may use GET or POST requests, Cache both
|
|
</span></span></span><span style="display:flex;"><span><span style="color:#626880;font-style:italic"></span> <span style="color:#ca9ee6">proxy_cache_methods</span> <span style="color:#a6d189">GET</span> <span style="color:#a6d189">POST</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#626880;font-style:italic"># Return 404 to all responses, except for those using our published DoH URI
|
|
</span></span></span><span style="display:flex;"><span><span style="color:#626880;font-style:italic"></span> <span style="color:#ca9ee6">location</span> <span style="color:#a6d189">/</span> <span style="color:#c6d0f5">{</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">try_files</span> <span style="color:#babbf1">$uri</span> <span style="color:#babbf1">$uri/</span> <span style="color:#c6d0f5">=</span>404<span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#c6d0f5">}</span>
|
|
</span></span><span style="display:flex;"><span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">ssl_protocols</span> <span style="color:#a6d189">TLSv1.2</span> <span style="color:#a6d189">TLSv1.3</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">proxy_ssl_ciphers</span> <span style="color:#a6d189">HIGH:!aNULL:!MD5</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#626880;font-style:italic"># This is our published DoH URI
|
|
</span></span></span><span style="display:flex;"><span><span style="color:#626880;font-style:italic"></span> <span style="color:#ca9ee6">location</span> <span style="color:#a6d189">/dns-query</span> <span style="color:#c6d0f5">{</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#626880;font-style:italic"># Proxy HTTP/1.1, clear the connection header to enable Keep-Alive
|
|
</span></span></span><span style="display:flex;"><span><span style="color:#626880;font-style:italic"></span> <span style="color:#ca9ee6">proxy_http_version</span> 1<span style="color:#a6d189">.1</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">proxy_set_header</span> <span style="color:#a6d189">Connection</span> <span style="color:#a6d189">""</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#626880;font-style:italic"># Enable Cache, and set the cache_key to include the request_body
|
|
</span></span></span><span style="display:flex;"><span><span style="color:#626880;font-style:italic"></span> <span style="color:#ca9ee6">proxy_cache</span> <span style="color:#a6d189">doh_cache</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#ca9ee6">proxy_cache_key</span> <span style="color:#babbf1">$scheme$proxy_host$uri$is_args$args$request_body</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#626880;font-style:italic"># proxy pass to dnsdist
|
|
</span></span></span><span style="display:flex;"><span><span style="color:#626880;font-style:italic"></span> <span style="color:#ca9ee6">proxy_pass</span> <span style="color:#a6d189">http://127.0.0.1:5300</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#626880;font-style:italic"># proxy pass address
|
|
</span></span></span><span style="display:flex;"><span><span style="color:#626880;font-style:italic"></span> <span style="color:#ca9ee6">proxy_set_header</span> <span style="color:#a6d189">X-Forwarded-For</span> <span style="color:#babbf1">$proxy_add_x_forwarded_for</span><span style="color:#c6d0f5">;</span>
|
|
</span></span><span style="display:flex;"><span> <span style="color:#c6d0f5">}</span>
|
|
</span></span><span style="display:flex;"><span><span style="color:#c6d0f5">}</span>
|
|
</span></span></code></pre></div><p>After restarting nginx with this configuration you can it to your web browser as a DNS over HTTPS resolver and once again checkout <a href="https://dnsleaktest.com">dnsleaktest</a> website and check if it is all working.</p>
|
|
<p>Hope this has been helpfull and if anybody has any way on how to make this guied better you can open a pull request or make an issue on the website’s <a href="https://code.cronyakatsuki.xyz/crony/website">repo</a>.</p>
|
|
</div>
|
|
</main>
|
|
<footer>
|
|
<div id="links">
|
|
<span><a href="https://code.cronyakatsuki.xyz">Code</a></span>
|
|
<span>|</span>
|
|
<span><a href="https://steamcommunity.com/id/CronyAkatsuki/">Steam</a></span>
|
|
<span>|</span>
|
|
<span><a href="https://osu.ppy.sh/users/18953565">Osu!</a></span>
|
|
<span>|</span>
|
|
<span><a href="https://anilist.co/user/CronyAkatsuki/">Anilist</a></span>
|
|
<span>|</span>
|
|
<span><a href="https://youtube.com/channel/UClFdlNlUipHG5Kit8GbFz5Q">Gaming Channel</a></span>
|
|
</div>
|
|
<div id="banners">
|
|
<a rel="noreferrer" href="/" target="_blank"><img src="/88x31.png"
|
|
alt="Me" title="Me" /></a>
|
|
<a rel="noreferrer" href="https://kernel.org" target="_blank"><img src="https://cyber.dabamos.de/88x31/linux_powered.gif"
|
|
alt="linux kernel" title="Best kernel in the world" /></a>
|
|
<a rel="noreferrer" href="https://debian.org" target="_blank"><img src="https://cyber.dabamos.de/88x31/debian.gif"
|
|
alt="debian" title="This website run's on debian" /></a>
|
|
<a rel="noreferrer" href="https://bitwarden.com" target="_blank"><img src="https://cyber.dabamos.de/88x31/bitwarden.gif"
|
|
alt="Bitwarden" title="Bitwarden/Vaultwarden for the win" /></a>
|
|
<a rel="noreferrer" target="_blank"><img src="https://cyber.dabamos.de/88x31/free.gif"
|
|
alt="foss" title="Foss is the way" /></a>
|
|
<a rel="noreferrer" href="https://neovim.io" target="_blank"><img src="/assets/badges/neovim.gif"
|
|
alt="Neovim" title="Written in neovim" /></a>
|
|
<a rel="noreferrer" href="https://landchad.net" target="_blank"><img src="https://landchad.net/pix/landchad.gif"
|
|
alt="LandChad" title="Get A Website!" /></a>
|
|
<a rel="noreferrer" href="https://poggerer.xyz" target="_blank"><img src="https://poggerer.xyz/88x31.png"
|
|
alt="Tulg" title="Tulg" /></a>
|
|
<a rel="noreferrer" href="https://arthurmelton.com" target="_blank"><img src="https://arthurmelton.com/88x31.png"
|
|
alt="AMTitan" title="AMTitan" /></a>
|
|
<a rel="noreferrer" href="https://aadi.net.in" target="_blank"><img src="https://aadi.net.in/88x31.png"
|
|
alt="Aadi" title="Aadi" /></a>
|
|
<a rel="noreferrer" href="https://bear.oops.wtf/" target="_blank"><img src="https://bear.oops.wtf/download/88x31.png"
|
|
alt="Bear" title="Bear" /></a>
|
|
</div>
|
|
</footer>
|
|
|
|
</body>
|
|
|
|
</html>
|