<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.2.0">Jekyll</generator><link href="https://terminaladdict.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://terminaladdict.com/" rel="alternate" type="text/html" /><updated>2020-12-24T11:21:50+13:00</updated><id>https://terminaladdict.com/feed.xml</id><subtitle>Linux and SysAdmin tips and tricks</subtitle><entry><title type="html">Animated Christmas Tree Written In Bash</title><link href="https://terminaladdict.com/bash/linux/2020/12/02/Animated-Christmas-Tree-Written-in-Bash.html" rel="alternate" type="text/html" title="Animated Christmas Tree Written In Bash" /><published>2020-12-02T00:00:00+13:00</published><updated>2020-12-02T00:00:00+13:00</updated><id>https://terminaladdict.com/bash/linux/2020/12/02/Animated-Christmas-Tree-Written-in-Bash</id><content type="html" xml:base="https://terminaladdict.com/bash/linux/2020/12/02/Animated-Christmas-Tree-Written-in-Bash.html">&lt;p&gt;It’s Christmas OMG OMG OMG OMG 🎄 🎅 🤶&lt;br /&gt;
So here is your &lt;a href=&quot;https://terminaladdict.com/&quot;&gt;TerminalAddict.com&lt;/a&gt; gift for 2020 🎁🎁🎁&lt;/p&gt;

&lt;h2 id=&quot;prerequisites&quot;&gt;Prerequisites&lt;/h2&gt;
&lt;p&gt;You must have bash installed 😂&lt;/p&gt;

&lt;h3 id=&quot;assumptions&quot;&gt;Assumptions&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;I’ll assume we have bash installed 😜&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;the-code&quot;&gt;The code&lt;/h2&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;EOF&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;' &amp;gt;&amp;gt; ~/xmas_tree.sh
#!/bin/bash

# tput is a command to manipulate the terminal, it can be used to change the color of text, apply effects, and generally brighten things up.
trap &quot;tput reset; tput cnorm; exit&quot; 2
clear
tput civis
lin=2
col=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$((&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;tput cols&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;
c=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$((&lt;/span&gt;col-1&lt;span class=&quot;k&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;
est=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$((&lt;/span&gt;c-2&lt;span class=&quot;k&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;
color=0

# Set the text color to green to write the tree
tput setaf 2; tput bold

# Write the tree
for ((i=1; i&amp;lt;40; i+=2))
{
    tput cup &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$lin&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$col&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;
    for ((j=1; j&amp;lt;=i; j++))
    {
        echo -n &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\*&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;
    }
    let lin++
    let col--
}

## Set the color to brown for the trunk
tput sgr0; tput setaf 130

# Write the Trunk in three lines
for ((i=1; i&amp;lt;=3; i++))
{
    tput cup &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$((&lt;/span&gt;lin++&lt;span class=&quot;k&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$c&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;
    echo 'mWm'
}

# Write a greeting
tput setaf 93; tput bold
tput cup &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$lin&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt; &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$((&lt;/span&gt;c &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;15&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;; echo Merry Christmas
tput cup &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$((&lt;/span&gt;lin &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt; &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$((&lt;/span&gt;c &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;15&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;; echo And a happy new year !!!!
let c++
k=1

# Configure lights and decorations
while true; do
    for ((i=1; i&amp;lt;=35; i++)) {
        # Turn off the lights
        [ &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$k&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt; -gt 1 ] &amp;amp;&amp;amp; {
            tput setaf 2; tput bold
            tput cup &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$[k&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;-1]&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt; &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;column&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$[k&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;-1]&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;; echo &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\*&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;
            unset line[&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;k-1]&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$i&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;]; unset column[&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;k-1]&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$i&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;]  # Array cleanup
        }

        li=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$((&lt;/span&gt;RANDOM &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;9&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;
        start=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$((&lt;/span&gt;c-li+2&lt;span class=&quot;k&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;
        co=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$((&lt;/span&gt;RANDOM &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;li-2&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; start&lt;span class=&quot;k&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;
        tput setaf &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$color&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;; tput bold   # Switch colors
        tput cup &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$li&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$co&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;
        echo o
        line[&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$k$i&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;]=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$li&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;
        column[&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$k$i&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;]=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$co&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;
        color=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$((&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;color+1&lt;span class=&quot;o&quot;&gt;)%&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;
    }
    k=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$((&lt;/span&gt;k &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;
done


EOF&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Now let’s run it&lt;/p&gt;
&lt;h2 id=&quot;execution&quot;&gt;Execution&lt;/h2&gt;
&lt;p&gt;Set execution:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;chmod &lt;/span&gt;755 ~/xmas_tree.sh&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Now run it:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;~/xmas_tree.sh&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;the-result&quot;&gt;The result&lt;/h2&gt;

&lt;p&gt;Check it out !!!&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://terminaladdict.com/assets/images/posts/thumbnails/bash_xmas_tree.gif&quot; alt=&quot;bash_xmas_tree.gif&quot; rel=&quot;lightbox&quot; class=&quot;shadow-lg rounded&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;happy-christmas-&quot;&gt;Happy Christmas! 🦌🦌🦌🦌🛷&lt;/h1&gt;</content><author><name>paul</name></author><category term="bash" /><category term="linux" /><summary type="html">It’s Christmas OMG OMG OMG OMG 🎄 🎅 🤶 So here is your TerminalAddict.com gift for 2020 🎁🎁🎁</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://terminaladdict.com/no-image.png" /><media:content medium="image" url="https://terminaladdict.com/no-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Awstats Static Reports And Nginx</title><link href="https://terminaladdict.com/bash/networking/2020/09/24/Awstats-static-reports-and-Nginx.html" rel="alternate" type="text/html" title="Awstats Static Reports And Nginx" /><published>2020-09-24T00:00:00+12:00</published><updated>2020-09-24T00:00:00+12:00</updated><id>https://terminaladdict.com/bash/networking/2020/09/24/Awstats-static-reports-and-Nginx</id><content type="html" xml:base="https://terminaladdict.com/bash/networking/2020/09/24/Awstats-static-reports-and-Nginx.html">&lt;p&gt;So, I run a few websites 😉 and most of those websites (including this one) I have Google Analytics installed.&lt;br /&gt;
But server logs &lt;em&gt;can&lt;/em&gt; provide different information. So I’m going to setup graphing and tracking my server access logs.&lt;/p&gt;

&lt;p&gt;So my steps are going to be:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Install &lt;a href=&quot;https://awstats.sourceforge.io/&quot; target=&quot;_blank&quot;&gt;Awstats&lt;/a&gt;, along with some prerequisites for CPAN, and creating a password file.&lt;/li&gt;
  &lt;li&gt;Install &lt;a href=&quot;https://www.cpan.org/&quot; target=&quot;_blank&quot;&gt;CPAN The Comprehensive Perl Archive Network&lt;/a&gt;, along with the GeoIP plugin.&lt;/li&gt;
  &lt;li&gt;Write a bash script to create, update, and graph, some results (as well as a wee PHP script to make life easier).&lt;/li&gt;
  &lt;li&gt;Profit!&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;prerequisites&quot;&gt;Prerequisites&lt;/h2&gt;
&lt;p&gt;I’m not going to talk you through setting up a Linux server, or Nginx, PHP-FPM (Fastcgi).&lt;/p&gt;

&lt;p&gt;I will assume that you have a running server.&lt;br /&gt;
Your linux server can be any flavour you like, I prefer &lt;a href=&quot;https://www.debian.org/&quot; target=&quot;_blank&quot;&gt;Debian&lt;/a&gt; and &lt;a href=&quot;https://ubuntu.com/&quot; target=&quot;_blank&quot;&gt;Ubuntu&lt;/a&gt; distros, and I prefer &lt;a href=&quot;https://wiki.debian.org/Aptitude&quot; target=&quot;_blank&quot;&gt;aptitude&lt;/a&gt; as a package manager; you can use whatever you like 🤗.&lt;/p&gt;

&lt;h3 id=&quot;assumptions&quot;&gt;Assumptions&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;I’ll assume we store the Awstats DB in /var/lib/awstats.&lt;/li&gt;
  &lt;li&gt;I’ll assume we store the static reports in /var/cache/awstats.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;installing-the-packages&quot;&gt;Installing the packages&lt;/h2&gt;
&lt;p&gt;Here we go:&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo aptitude install awstats libgeoip-dev build-essential openssl&lt;/code&gt;&lt;/p&gt;

&lt;h3 id=&quot;installing-the-geoip-plugin&quot;&gt;Installing the GeoIP plugin&lt;/h3&gt;
&lt;p&gt;So first we need to setup CPAN:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;cpan
Loading internal logger. Log::Log4perl recommended &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;better logging

cpan shell &lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt; CPAN exploration and modules installation &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;v2.28&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
Enter &lt;span class=&quot;s1&quot;&gt;'h'&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;help.

cpan[1]&amp;gt;  &lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Now, while in the CPAN shell, let’s install some stuff.&lt;br /&gt;
Firstly, CPAN itself, and then the GeoIP plugin.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cpan[1]&amp;gt; make install&lt;/code&gt;&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cpan[1]&amp;gt; install Bundle::CPAN&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;That’ll get you up and running ready to install from cpan.&lt;br /&gt;
Now let’s install the GeoIP plugin:&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cpan[1]&amp;gt; install Geo::IP&lt;/code&gt;&lt;/p&gt;

&lt;h2 id=&quot;setting-up-nginx&quot;&gt;Setting up Nginx&lt;/h2&gt;
&lt;p&gt;So, a few prerequisites are needed for Nginx to behave properly.&lt;br /&gt;
Firstly, make sure you have PHP running using fastcgi (I’m not showing you how to do this in this doc).&lt;/p&gt;

&lt;p&gt;Next, let’s make sure logging is separate for each website:&lt;br /&gt;
In my &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;server {&lt;/code&gt; block I have the following lines for logging:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;server_name terminaladdict.com&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
access_log /var/log/nginx/terminaladdict.com-access.log&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
error_log /var/log/nginx/terminaladdict.com-error.log&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;I’m going to add some config to my server block specifically for awstats:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;location ^~ /awstats &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;nb&quot;&gt;alias&lt;/span&gt; /var/cache/awstats/terminaladdict.com&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	location ~ &lt;span class=&quot;se&quot;&gt;\.&lt;/span&gt;php&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
		fastcgi_split_path_info ^&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;.+&lt;span class=&quot;se&quot;&gt;\.&lt;/span&gt;php&lt;span class=&quot;o&quot;&gt;)(&lt;/span&gt;/.+&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$;&lt;/span&gt;
		fastcgi_pass unix:/var/run/php/php7.3-fpm.sock&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
		fastcgi_param SCRIPT_FILENAME &lt;span class=&quot;nv&quot;&gt;$request_filename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
		include fastcgi_params&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
	auth_basic &lt;span class=&quot;s2&quot;&gt;&quot;Website Statistics&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	auth_basic_user_file /var/lib/awstats/.htpasswd&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
location ^~ /awstats-icon &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;nb&quot;&gt;alias&lt;/span&gt; /usr/share/awstats/icon/&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Now reload nginx &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;systemctl reload nginx.service&lt;/code&gt;&lt;/p&gt;

&lt;h3 id=&quot;password-protect-our-stats&quot;&gt;Password protect our stats&lt;/h3&gt;
&lt;p&gt;Let’s not go public with our stats 😆 &lt;br /&gt;
In the Nginx config above I provided for password protection, so let’s create that .htpasswd file:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;printf&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Hi_my_name_is:&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;openssl passwd &lt;span class=&quot;nt&quot;&gt;-apr1&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; /var/lib/awstats/.htpasswd
Password: &lt;span class=&quot;k&quot;&gt;*********&lt;/span&gt;
Verifying - Password: &lt;span class=&quot;k&quot;&gt;*********&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;setting-up-awstats&quot;&gt;Setting up Awstats&lt;/h2&gt;
&lt;p&gt;Right, so for whatever reason, awstats installs a cron job that doesn’t seem to work. &lt;br /&gt;
So let’s turn it off:&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;echo &quot;&quot; &amp;gt; /etc/cron.d/awstats&lt;/code&gt; &lt;br /&gt;
phew 😆&lt;/p&gt;

&lt;p&gt;Now let’s create an awstats config for our website. &lt;br /&gt;
Awstats expects the config to be named “awstats.website.ext.conf”.&lt;br /&gt;
Something like:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;awstats.terminaladdict.com.conf&lt;/li&gt;
  &lt;li&gt;awstats.example.co.nz.conf&lt;/li&gt;
  &lt;li&gt;awstats.subdomain.example.org.nz.conf&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I’m creating a config for terminaladdict.com, so here we have it:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;LogFile&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;/var/log/nginx/terminaladdict.com-access.log&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;SiteDomain&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;terminaladdict.com&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;HostAliases&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;www.terminaladdict.com&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;DirIcons&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;/awstats-icon&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;DirData&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;/var/lib/awstats&quot;&lt;/span&gt;
DNSLookup &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; 1
&lt;span class=&quot;nv&quot;&gt;LoadPlugin&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;geoip GEOIP_STANDARD /usr/share/GeoIP/GeoIP.dat&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;br /&gt;
Here’s a warning !
If your website is super busy, probably disable DNSLookup, by setting it to 0
&lt;br /&gt;
DNSLooup = 1 will slow things down &lt;strong&gt;A LOT&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;the-bash-script&quot;&gt;The bash script&lt;/h2&gt;
&lt;p&gt;While I was setting this up I read many articles about configuring nginx to using cgi-bin.php with fastcgi.&lt;br /&gt;
For me, it just didn’t work, and I got bored trying to figure out why it didn’t work!&lt;/p&gt;

&lt;p&gt;So I wrote my own little bash script to update awstats db, generate static reports, and build an index.php for some of the directories, just for ease of use.&lt;/p&gt;

&lt;p&gt;Here is my script:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;#!/bin/bash&lt;/span&gt;

&lt;span class=&quot;nv&quot;&gt;AWSTATS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/usr/lib/cgi-bin/awstats.pl
&lt;span class=&quot;nv&quot;&gt;DIR&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/var/cache/awstats
&lt;span class=&quot;nv&quot;&gt;YEAR&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;date&lt;/span&gt; +%Y&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;MONTH&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;date&lt;/span&gt; +%m&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;PHPFILE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;
&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang='en'&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset='utf-8'&amp;gt;
    &amp;lt;meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no'&amp;gt;
    &amp;lt;title&amp;gt;Awstats&amp;lt;/title&amp;gt;
    &amp;lt;link rel='stylesheet' href='https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css'&amp;gt;
    &amp;lt;meta name='description' content='Awstats for websites hosted on Net Enterprises Ltd' /&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;

&amp;lt;div class='container-fluid pt-5'&amp;gt;
    &amp;lt;div class='container'&amp;gt;
        &amp;lt;div class='row'&amp;gt;
            &amp;lt;div class='col-md-12'&amp;gt;
                &amp;lt;h3&amp;gt;Stuff found in this directory&amp;lt;/h3&amp;gt;
                &amp;lt;ul class='list-unstyled'&amp;gt;
&amp;lt;?php
&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\$&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;dir = '.';
&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\$&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;files = scandir(&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\$&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;dir);
&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\$&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;excludes = Array('.', '..', 'index.php');

foreach(&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\$&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;files as &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\$&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;file) {
    if(!in_array(&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\$&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;file, &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\$&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;excludes)) {
        echo '                  &amp;lt;li class=&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\'&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;p-3&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\'&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;gt;&amp;lt;a data-toggle=&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\'&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;tooltip&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\'&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; data-original-title=&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\'&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;'.&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\$&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;file.'&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\'&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; data-placement=&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\'&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;bottom&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\'&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; href=&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\'&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;'.&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\$&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;file.'&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\'&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; class=&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\'&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;btn btn-primary btn-lg&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\'&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;gt;'.&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\$&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;file.'&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;' . PHP_EOL;
    }
}
?&amp;gt;
                &amp;lt;/ul&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;script src='https://code.jquery.com/jquery-3.5.1.slim.min.js'&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src='https://unpkg.com/@popperjs/core@2'&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src='https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js'&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;c &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;/bin/ls &lt;span class=&quot;nt&quot;&gt;-1&lt;/span&gt; /etc/awstats/awstats.&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;.conf 2&amp;gt;/dev/null | /bin/sed &lt;span class=&quot;s1&quot;&gt;'s/^\/etc\/awstats\/awstats\.\(.*\)\.conf/\1/'&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt; &lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; /etc/awstats/awstats.conf &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;do
    &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$DIR&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$c&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$YEAR&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$MONTH&lt;/span&gt;/
    &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;d &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$DIR&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$DIR&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$c&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$DIR&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$c&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$YEAR&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;do
        &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$PHPFILE&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$d&lt;/span&gt;/index.php
    &lt;span class=&quot;k&quot;&gt;done&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;$AWSTATS&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-config&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$c&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-update&lt;/span&gt;

    &lt;span class=&quot;c&quot;&gt;# report for the year&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;$AWSTATS&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-config&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$c&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-output&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-month&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;all &lt;span class=&quot;nt&quot;&gt;-staticlinks&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$DIR&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$c&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$YEAR&lt;/span&gt;/awstats.yearly.report.&lt;span class=&quot;nv&quot;&gt;$c&lt;/span&gt;.html
    &lt;span class=&quot;nb&quot;&gt;ln&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-sf&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$DIR&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$c&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$YEAR&lt;/span&gt;/awstats.yearly.report.&lt;span class=&quot;nv&quot;&gt;$c&lt;/span&gt;.html &lt;span class=&quot;nv&quot;&gt;$DIR&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$c&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$YEAR&lt;/span&gt;/1-start-here.html

    &lt;span class=&quot;c&quot;&gt;# report the for the current month&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;$AWSTATS&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-config&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$c&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-output&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-staticlinks&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$DIR&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$c&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$YEAR&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$MONTH&lt;/span&gt;/awstats.&lt;span class=&quot;nv&quot;&gt;$c&lt;/span&gt;.html
    &lt;span class=&quot;nb&quot;&gt;ln&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-sf&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$DIR&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$c&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$YEAR&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$MONTH&lt;/span&gt;/awstats.&lt;span class=&quot;nv&quot;&gt;$c&lt;/span&gt;.html &lt;span class=&quot;nv&quot;&gt;$DIR&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$c&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$YEAR&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$MONTH&lt;/span&gt;/index.html

    &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;stat &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;alldomains allhosts lasthosts unknownip alllogins lastlogins allrobots lastrobots urldetail urlentry urlexit browserdetail osdetail unknownbrowser unknownos refererse refererpages keyphrases keywords errors404 downloads
    &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;$AWSTATS&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-config&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$c&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$stat&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-month&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;all &lt;span class=&quot;nt&quot;&gt;-staticlinks&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$DIR&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$c&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$YEAR&lt;/span&gt;/awstats.&lt;span class=&quot;nv&quot;&gt;$c&lt;/span&gt;.&lt;span class=&quot;nv&quot;&gt;$stat&lt;/span&gt;.html
        &lt;span class=&quot;nv&quot;&gt;$AWSTATS&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-config&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$c&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-output&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$stat&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-staticlinks&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$DIR&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$c&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$YEAR&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$MONTH&lt;/span&gt;/awstats.&lt;span class=&quot;nv&quot;&gt;$c&lt;/span&gt;.&lt;span class=&quot;nv&quot;&gt;$stat&lt;/span&gt;.html
    &lt;span class=&quot;k&quot;&gt;done
done&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;What the script does is:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Set up some vairable, including a variable named PHPFILE, that creates a PHP file for some directories.&lt;/li&gt;
  &lt;li&gt;in a for loop, for each awstats.{websitename}.conf do
    &lt;ul&gt;
      &lt;li&gt;make a directory if needed (mkdir -p)&lt;/li&gt;
      &lt;li&gt;a new for loop, that creates a PHP file in the root directory, and the $YEAR directory&lt;/li&gt;
      &lt;li&gt;Updates the stats &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$AWSTATS -config=$c -update&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;create some soft links for ease of use&lt;/li&gt;
      &lt;li&gt;a nested for loop that creates reports for the year, and the month&lt;/li&gt;
      &lt;li&gt;1). &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$AWSTATS -config=$c -output=$stat -month=all -staticlinks &amp;gt; $DIR/$c/$YEAR/awstats.$c.$stat.html&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;2). &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$AWSTATS -config=$c -output=$stat -staticlinks &amp;gt; $DIR/$c/$YEAR/$MONTH/awstats.$c.$stat.html&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;profit!&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And here is the result:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;/assets/php/awstats.index.php&quot; target=&quot;_blank&quot;&gt;The PHP file that the script creates&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/assets/php/awstats.yearly.ternminaladdict.com.html&quot; target=&quot;_blank&quot;&gt;The Awstats Yearly report&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;/assets/php/awstats.monthly.ternminaladdict.com.html&quot; target=&quot;_blank&quot;&gt;The Awstats Monthly report&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;automating&quot;&gt;Automating&lt;/h2&gt;
&lt;p&gt;And of course, chuck it in cron so it updates regularly. &lt;br /&gt;
I run mine at 17 minutes passed the hour, because - well I dunno - 17 seemed like a fun number to use 🤪. &lt;br /&gt;
I stored the script in /usr/local/bin and called it awstats.update_and_build.sh&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;# awstats&lt;/span&gt;
17 &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;   root    /usr/local/bin/awstats.update_and_build.sh &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; /dev/null 2&amp;gt;&amp;amp;1&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Happy stats collecting !&lt;/p&gt;</content><author><name>paul</name></author><category term="bash" /><category term="networking" /><summary type="html">So, I run a few websites 😉 and most of those websites (including this one) I have Google Analytics installed. But server logs can provide different information. So I’m going to setup graphing and tracking my server access logs.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://terminaladdict.com/no-image.png" /><media:content medium="image" url="https://terminaladdict.com/no-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Graphing Speedtest Results</title><link href="https://terminaladdict.com/bash/networking/2020/09/21/graphing-speedtest-results.html" rel="alternate" type="text/html" title="Graphing Speedtest Results" /><published>2020-09-21T00:00:00+12:00</published><updated>2020-09-21T00:00:00+12:00</updated><id>https://terminaladdict.com/bash/networking/2020/09/21/graphing-speedtest-results</id><content type="html" xml:base="https://terminaladdict.com/bash/networking/2020/09/21/graphing-speedtest-results.html">&lt;p&gt;I can be described as a network engineer, sometimes, and sometimes a system admin. As such, keeping track of how customers internet is working is reasonably important.&lt;br /&gt;
Most customers use &lt;a href=&quot;https://www.speedtest.net/&quot; target=&quot;_blank&quot;&gt;Speedtest.net&lt;/a&gt; as a way of testing their internet connection, so I figured I would clobber together a script that keeps a bit of history, and make some pretty graphs 😅.&lt;/p&gt;

&lt;p&gt;So my steps are going to be:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Install &lt;a href=&quot;https://oss.oetiker.ch/rrdtool/doc/index.en.html&quot; target=&quot;_blank&quot;&gt;rrdtool&lt;/a&gt;, &lt;a href=&quot;https://www.gnu.org/software/gawk/manual/gawk.html&quot; target=&quot;_blank&quot;&gt;Gawk&lt;/a&gt;, and &lt;a href=&quot;https://www.gnu.org/software/grep/&quot; target=&quot;_blank&quot;&gt;grep&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Install &lt;a href=&quot;https://www.speedtest.net/apps/cli&quot; target=&quot;_blank&quot;&gt;Ookla speedtest cli&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Write a bash script to create, update, and graph, some results&lt;/li&gt;
  &lt;li&gt;Profit!&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;prerequisites&quot;&gt;Prerequisites&lt;/h2&gt;
&lt;p&gt;I’m not going to talk you through setting up a Linux server.&lt;/p&gt;

&lt;p&gt;I will assume that you have a running server.&lt;br /&gt;
Your linux server can be any flavour you like, I prefer &lt;a href=&quot;https://www.debian.org/&quot; target=&quot;_blank&quot;&gt;Debian&lt;/a&gt; and &lt;a href=&quot;https://ubuntu.com/&quot; target=&quot;_blank&quot;&gt;Ubuntu&lt;/a&gt; distros, and I prefer &lt;a href=&quot;https://wiki.debian.org/Aptitude&quot; target=&quot;_blank&quot;&gt;aptitude&lt;/a&gt; as a package manager; you can use whatever you like 🤗.&lt;/p&gt;

&lt;p&gt;I’m also not going to talk you through setting up a web server .. sort that out yourself 😜.&lt;/p&gt;

&lt;p&gt;You NEED &lt;strong&gt;unlimited&lt;/strong&gt; data on your internet!!!!&lt;br /&gt;
Let me say that again .. &lt;strong&gt;YOU NEED UNLIMITED DATA ON YOUR INTERNET !!!&lt;/strong&gt;&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;This script will thrash your internet usage!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;installing-the-packages-and-setting-up-directories&quot;&gt;Installing the packages, and setting up directories&lt;/h2&gt;
&lt;p&gt;Right, let’s start with installing &lt;a href=&quot;https://oss.oetiker.ch/rrdtool/doc/index.en.html&quot; target=&quot;_blank&quot;&gt;rrdtool&lt;/a&gt;, &lt;a href=&quot;https://www.gnu.org/software/gawk/manual/gawk.html&quot; target=&quot;_blank&quot;&gt;Gawk&lt;/a&gt;, and &lt;a href=&quot;https://www.gnu.org/software/grep/&quot; target=&quot;_blank&quot;&gt;grep&lt;/a&gt;&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo aptitude install rrdtool gawk grep&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;That’s pretty easy !&lt;/p&gt;

&lt;h3 id=&quot;install-ookla-speedtest-cli&quot;&gt;Install Ookla Speedtest cli&lt;/h3&gt;
&lt;p&gt;So you can head over to the &lt;a href=&quot;https://www.speedtest.net/apps/cli&quot; target=&quot;_blank&quot;&gt;Ookla Speedtest cli&lt;/a&gt; website and download the appropriate package. In my case it’s the Linux x86_64 package, which is at version 1.0.0.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wget https://bintray.com/ookla/download/download_file?file_path=ookla-speedtest-1.0.0-x86_64-linux.tgz -O /tmp/speedtest.tgz&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now let’s unpack it:&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tar xvfz /tmp/speedtest.tgz -C /tmp&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And put it in a usable spot on the OS:&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo mv /tmp/speedtest /usr/local/bin/speedtest&lt;/code&gt;&lt;/p&gt;

&lt;h3 id=&quot;running-speedtest-cli&quot;&gt;Running Speedtest cli&lt;/h3&gt;
&lt;p&gt;The first time you run speedtest you will be asked to agree to a license:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;/usr/local/bin/speedtest
&lt;span class=&quot;o&quot;&gt;==============================================================================&lt;/span&gt;

You may only use this Speedtest software and information generated
from it &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;personal, non-commercial use, through a &lt;span class=&quot;nb&quot;&gt;command &lt;/span&gt;line
interface on a personal computer. Your use of this software is subject
to the End User License Agreement, Terms of Use and Privacy Policy at
these URLs:

        https://www.speedtest.net/about/eula
        https://www.speedtest.net/about/terms
        https://www.speedtest.net/about/privacy

&lt;span class=&quot;o&quot;&gt;==============================================================================&lt;/span&gt;

Do you accept the license? &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;type &lt;/span&gt;YES to accept]:&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Now you’re ready to go!&lt;/p&gt;

&lt;p&gt;You can list out the nearest servers like so:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;/usr/local/bin/speedtest &lt;span class=&quot;nt&quot;&gt;-L&lt;/span&gt;
Closest servers:

    ID  Name                           Location             Country
&lt;span class=&quot;o&quot;&gt;==============================================================================&lt;/span&gt;
  5469  MyRepublic Limited             Auckland             New Zealand
  5749  Vocusgroup NZ                  Auckland             New Zealand
 11327  Spark New Zealand              Auckland             New Zealand
  2720  WorldNet                       Auckland             New Zealand
  4953  Vodafone New Zealand           Auckland             New Zealand
   721  WorldxChange Comm              Auckland             New Zealand
 13676  speedtest.nzpbx.com            Auckland             New Zealand
 12932  Feenix Communications Limited  Auckland             New Zealand
 16805  Nova Energy                    AUCKLAND             New Zealand
 25477  Devoli                         Auckland             New Zealand&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;This particular customer I am testing from is connected through &lt;a href=&quot;https://www.vocus.co.nz/&quot; target=&quot;_blank&quot;&gt;Vocus&lt;/a&gt;.&lt;br /&gt;
So I’m going to use &lt;a href=&quot;https://www.vocus.co.nz/&quot; target=&quot;_blank&quot;&gt;Vocus&lt;/a&gt; to test against.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;/usr/local/bin/speedtest &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; 5749

   Speedtest by Ookla

     Server: Vocusgroup NZ - Auckland &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; 5749&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
        ISP: Vocus Communications
    Latency:     5.10 ms   &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;0.37 ms jitter&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
   Download:   844.16 Mbps &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;data used: 808.7 MB&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
     Upload:   548.05 Mbps &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;data used: 267.4 MB&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
Packet Loss:     0.0%
 Result URL: https://www.speedtest.net/result/c/1ff5533b-b0de-42c5-bd14-24c299cfc249&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Sweet !&lt;/p&gt;

&lt;h3 id=&quot;create-a-directory&quot;&gt;Create a directory&lt;/h3&gt;
&lt;p&gt;Ok, so now let’s create a directory to store history, and images.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo mkdir /var/www/html/rrd&lt;/code&gt;&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo chown paul:paul /var/www/html/rrd&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Note: I have changed the owner of the directory to the user ‘paul’. Change to whatever user you’re going to be running this script as.&lt;/p&gt;

&lt;h2 id=&quot;the-rrd-script&quot;&gt;The RRD Script&lt;/h2&gt;
&lt;p&gt;Ok, so here’s where the magic happens. So let’s skip straight to the script:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;#!/bin/bash&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# generate a speedtest result&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# 5749 server is Vocus&lt;/span&gt;
/usr/local/bin/speedtest &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; 5749 &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; no &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; /tmp/speedtest.txt 2&amp;gt;/dev/null

&lt;span class=&quot;nv&quot;&gt;TRAF&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/var/www/html/rrd

        &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;create&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
                /usr/bin/rrdtool create &lt;span class=&quot;nv&quot;&gt;$TRAF&lt;/span&gt;/upload.rrd &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; 60 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                DS:upload:GAUGE:600:0:U &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                RRA:AVERAGE:0.5:1:4320 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                RRA:AVERAGE:0.5:1440:3 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                RRA:MIN:0.5:1440:3 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                RRA:MAX:0.5:1440:3
                /usr/bin/rrdtool create &lt;span class=&quot;nv&quot;&gt;$TRAF&lt;/span&gt;/download.rrd &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; 60 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                DS:download:GAUGE:600:0:U &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                RRA:AVERAGE:0.5:1:4320 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                RRA:AVERAGE:0.5:1440:3 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                RRA:MIN:0.5:1440:3 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                RRA:MAX:0.5:1440:3
                /usr/bin/rrdtool create &lt;span class=&quot;nv&quot;&gt;$TRAF&lt;/span&gt;/echoreply.rrd &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; 60 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                DS:echoreply:GAUGE:600:0:U &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                RRA:AVERAGE:0.5:1:4320 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                RRA:AVERAGE:0.5:1440:3 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                RRA:MIN:0.5:1440:3 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                RRA:MAX:0.5:1440:3
                &lt;span class=&quot;p&quot;&gt;;;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;update&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
                /usr/bin/rrdtool update &lt;span class=&quot;nv&quot;&gt;$TRAF&lt;/span&gt;/upload.rrd N:&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; /tmp/speedtest.txt | &lt;span class=&quot;nb&quot;&gt;grep &lt;/span&gt;Upload | &lt;span class=&quot;nb&quot;&gt;awk&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'{print $3}'&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;
                /usr/bin/rrdtool update &lt;span class=&quot;nv&quot;&gt;$TRAF&lt;/span&gt;/download.rrd N:&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; /tmp/speedtest.txt | &lt;span class=&quot;nb&quot;&gt;grep &lt;/span&gt;Download | &lt;span class=&quot;nb&quot;&gt;awk&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'{print $3}'&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;
                /usr/bin/rrdtool update &lt;span class=&quot;nv&quot;&gt;$TRAF&lt;/span&gt;/echoreply.rrd N:&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; /tmp/speedtest.txt | &lt;span class=&quot;nb&quot;&gt;grep &lt;/span&gt;Latency | &lt;span class=&quot;nb&quot;&gt;awk&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'{print $2}'&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;
                &lt;span class=&quot;p&quot;&gt;;;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;graph&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
                /usr/bin/rrdtool graph &lt;span class=&quot;nv&quot;&gt;$TRAF&lt;/span&gt;/upload.png &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;--start&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;-3day&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;BACK#000000&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;SHADEA#000000&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;SHADEB#000000&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;FONT#DDDDDD&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;CANVAS#202020&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;GRID#666666&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;MGRID#AAAAAA&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;FRAME#202020&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ARROW#FFFFFF&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-u&lt;/span&gt; 1.1 &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt; 0 &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Upload&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-w&lt;/span&gt; 1100 &lt;span class=&quot;nt&quot;&gt;-h&lt;/span&gt; 250 &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Upload Speed - &lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;/bin/date +%A&lt;span class=&quot;s2&quot;&gt;&quot;, &quot;&lt;/span&gt;%d&lt;span class=&quot;s2&quot;&gt;&quot; &quot;&lt;/span&gt;%B&lt;span class=&quot;s2&quot;&gt;&quot; &quot;&lt;/span&gt;%Y&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                DEF:upload&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$TRAF&lt;/span&gt;/upload.rrd:upload:AVERAGE &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                AREA:upload&lt;span class=&quot;se&quot;&gt;\#&lt;/span&gt;FFFF00:&lt;span class=&quot;s2&quot;&gt;&quot;Upload speed (Mbit/s)&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                GPRINT:upload:MIN:&lt;span class=&quot;s2&quot;&gt;&quot;Min&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; %3.2lf &quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                GPRINT:upload:MAX:&lt;span class=&quot;s2&quot;&gt;&quot;Max&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; %3.2lf&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                GPRINT:upload:LAST:&lt;span class=&quot;s2&quot;&gt;&quot;Current&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; %3.2lf&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\j&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                COMMENT:&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\\&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;n&quot;&lt;/span&gt;

                /usr/bin/rrdtool graph &lt;span class=&quot;nv&quot;&gt;$TRAF&lt;/span&gt;/download.png &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;--start&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;-3day&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;BACK#000000&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;SHADEA#000000&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;SHADEB#000000&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;FONT#DDDDDD&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;CANVAS#202020&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;GRID#666666&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;MGRID#AAAAAA&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;FRAME#202020&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ARROW#FFFFFF&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-u&lt;/span&gt; 1.1 &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt; 0 &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Download&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-w&lt;/span&gt; 1100 &lt;span class=&quot;nt&quot;&gt;-h&lt;/span&gt; 250 &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Download Speed - &lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;/bin/date +%A&lt;span class=&quot;s2&quot;&gt;&quot;, &quot;&lt;/span&gt;%d&lt;span class=&quot;s2&quot;&gt;&quot; &quot;&lt;/span&gt;%B&lt;span class=&quot;s2&quot;&gt;&quot; &quot;&lt;/span&gt;%Y&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                DEF:download&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$TRAF&lt;/span&gt;/download.rrd:download:AVERAGE &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                AREA:download&lt;span class=&quot;se&quot;&gt;\#&lt;/span&gt;00FF00:&lt;span class=&quot;s2&quot;&gt;&quot;Download speed (Mbit/s)&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                GPRINT:download:MIN:&lt;span class=&quot;s2&quot;&gt;&quot;Min&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; %3.2lf &quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                GPRINT:download:MAX:&lt;span class=&quot;s2&quot;&gt;&quot;Max&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; %3.2lf&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                GPRINT:download:LAST:&lt;span class=&quot;s2&quot;&gt;&quot;Current&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; %3.2lf&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\j&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                COMMENT:&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\\&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;n&quot;&lt;/span&gt;

                /usr/bin/rrdtool graph &lt;span class=&quot;nv&quot;&gt;$TRAF&lt;/span&gt;/echoreply.png &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;--start&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;-3day&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;BACK#000000&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;SHADEA#000000&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;SHADEB#000000&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;FONT#DDDDDD&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;CANVAS#202020&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;GRID#666666&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;MGRID#AAAAAA&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;FRAME#202020&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ARROW#FFFFFF&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;-u&lt;/span&gt; 1.1 &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt; 0 &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Ping&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-w&lt;/span&gt; 1100 &lt;span class=&quot;nt&quot;&gt;-h&lt;/span&gt; 250 &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Ping Response - &lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;/bin/date +%A&lt;span class=&quot;s2&quot;&gt;&quot;, &quot;&lt;/span&gt;%d&lt;span class=&quot;s2&quot;&gt;&quot; &quot;&lt;/span&gt;%B&lt;span class=&quot;s2&quot;&gt;&quot; &quot;&lt;/span&gt;%Y&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                DEF:echoreply&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$TRAF&lt;/span&gt;/echoreply.rrd:echoreply:AVERAGE &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                AREA:echoreply&lt;span class=&quot;se&quot;&gt;\#&lt;/span&gt;FF0000:&lt;span class=&quot;s2&quot;&gt;&quot;Ping Response (ms)&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                GPRINT:echoreply:MIN:&lt;span class=&quot;s2&quot;&gt;&quot;Min&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; %3.2lf &quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                GPRINT:echoreply:MAX:&lt;span class=&quot;s2&quot;&gt;&quot;Max&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; %3.2lf&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                GPRINT:echoreply:LAST:&lt;span class=&quot;s2&quot;&gt;&quot;Current&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; %3.2lf&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\j&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
                COMMENT:&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\\&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;n&quot;&lt;/span&gt;
                &lt;span class=&quot;p&quot;&gt;;;&lt;/span&gt;

        &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
                &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Invalid option.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;;&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;esac&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;lets-do-some-splaining&quot;&gt;Let’s do some ‘splaining&lt;/h3&gt;
&lt;p&gt;So firstly, copy everything, save it in a file (I called mine speedtest_rrd.sh), and chmod appropriately.&lt;br /&gt;
Let me make an assumption that all your binary or executable files are in ~/bin.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;chmod 755 ~/bin/speedtest_rrd.sh&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The script can take one argument ( $1 ).&lt;/p&gt;

&lt;p&gt;Argument 1: (create)&lt;br /&gt;
This creates the rrd files to store history in, and creates some rrd info that we are going to display.&lt;/p&gt;

&lt;p&gt;Argument 2: (update)&lt;br /&gt;
This updates the rrd database with new values.&lt;/p&gt;

&lt;p&gt;Argument 3: (graph)&lt;br /&gt;
This draws the pretty graphs !&lt;/p&gt;

&lt;p&gt;You may have noticed right at the very beginning of the script this line:&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/usr/local/bin/speedtest -s 5749 -p no &amp;gt; /tmp/speedtest.txt 2&amp;gt;/dev/null&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This runs the speedtest cli, and saves the output into your /tmp directory.&lt;/p&gt;

&lt;h2 id=&quot;running-the-script&quot;&gt;Running the script&lt;/h2&gt;
&lt;p&gt;Now let’s run it, and schedule it, then look at the results.&lt;/p&gt;

&lt;h3 id=&quot;running-the-script-manually&quot;&gt;Running the script manually&lt;/h3&gt;
&lt;p&gt;Firstly we need to create the rrd database:&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/bin/speedtest_rrd.sh create&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;result:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt; /var/www/html/rrd/&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;.rrd
&lt;span class=&quot;nt&quot;&gt;-rw-r--r--&lt;/span&gt; 1 paul paul 35840 Sep 20 22:20 /var/www/html/rrd/download.rrd
&lt;span class=&quot;nt&quot;&gt;-rw-r--r--&lt;/span&gt; 1 paul paul 35840 Sep 20 22:20 /var/www/html/rrd/echoreply.rrd
&lt;span class=&quot;nt&quot;&gt;-rw-r--r--&lt;/span&gt; 1 paul paul 35840 Sep 20 22:20 /var/www/html/rrd/upload.rrd&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;simple !&lt;/p&gt;

&lt;p&gt;Now let’s do a test:&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/bin/speedtest_rrd.sh update&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and now, let’s create a graph:&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/bin/speedtest_rrd.sh graph&lt;/code&gt;&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt; /var/www/html/rrd/
total 188
&lt;span class=&quot;nt&quot;&gt;-rw-rw-r--&lt;/span&gt; 1 paul paul 28167 Sep 20 22:20 download.png
&lt;span class=&quot;nt&quot;&gt;-rw-r--r--&lt;/span&gt; 1 paul paul 35840 Sep 20 22:20 download.rrd
&lt;span class=&quot;nt&quot;&gt;-rw-rw-r--&lt;/span&gt; 1 paul paul 27113 Sep 20 22:20 echoreply.png
&lt;span class=&quot;nt&quot;&gt;-rw-r--r--&lt;/span&gt; 1 paul paul 35840 Sep 20 22:20 echoreply.rrd
&lt;span class=&quot;nt&quot;&gt;-rw-rw-r--&lt;/span&gt; 1 paul paul 21572 Sep 20 22:20 upload.png
&lt;span class=&quot;nt&quot;&gt;-rw-r--r--&lt;/span&gt; 1 paul paul 35840 Sep 20 22:20 upload.rrd&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Alright ! we have some data !&lt;/p&gt;

&lt;h3 id=&quot;scheduling-the-script&quot;&gt;Scheduling the script&lt;/h3&gt;
&lt;p&gt;Ok, so now we have some data, let’s start auto running the data collection.&lt;/p&gt;

&lt;p&gt;Remember me saying at the beginning you need unlimited data on your internet?&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;&lt;br /&gt;
Let me say that again .. &lt;strong&gt;YOU NEED UNLIMITED DATA ON YOUR INTERNET !!!&lt;/strong&gt; &lt;br /&gt;
This script will thrash your internet usage!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So with that warning out of the way, let’s chuck it in cron:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;*/5 *   * * *   paul /home/paul/bin/speedtest_rrd.sh update &amp;gt; /dev/null 2&amp;gt;&amp;amp;1 &amp;amp;&amp;amp; /home/paul/bin/speedtest_rrd.sh graph &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; /etc/crontab&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;note: I am running this script as the user ‘paul’. Change to whatever user you are running this script as.&lt;/p&gt;

&lt;h2 id=&quot;the-result&quot;&gt;The result&lt;/h2&gt;

&lt;p&gt;That’s it! we’re running. Let that script chug away for a few days, and you’ll get a result that looks like this:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://terminaladdict.com/assets/images/posts/thumbnails/download_graph.png&quot; alt=&quot;download_graph.png&quot; rel=&quot;lightbox&quot; class=&quot;shadow-lg rounded&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://terminaladdict.com/assets/images/posts/thumbnails/upload_graph.png&quot; alt=&quot;upload_graph.png&quot; rel=&quot;lightbox&quot; class=&quot;shadow-lg rounded&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://terminaladdict.com/assets/images/posts/thumbnails/echoreply_graph.png&quot; alt=&quot;echoreply_graph.png&quot; rel=&quot;lightbox&quot; class=&quot;shadow-lg rounded&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Happy speedtesting !&lt;/p&gt;</content><author><name>paul</name></author><category term="bash" /><category term="networking" /><summary type="html">I can be described as a network engineer, sometimes, and sometimes a system admin. As such, keeping track of how customers internet is working is reasonably important. Most customers use Speedtest.net as a way of testing their internet connection, so I figured I would clobber together a script that keeps a bit of history, and make some pretty graphs 😅.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://terminaladdict.com/no-image.png" /><media:content medium="image" url="https://terminaladdict.com/no-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Streaming A Zoneminder Monitor To A Web Site</title><link href="https://terminaladdict.com/php/networking/2020/09/11/cctv-streaming-to-a-website.html" rel="alternate" type="text/html" title="Streaming A Zoneminder Monitor To A Web Site" /><published>2020-09-11T00:00:00+12:00</published><updated>2020-09-11T00:00:00+12:00</updated><id>https://terminaladdict.com/php/networking/2020/09/11/cctv-streaming-to-a-website</id><content type="html" xml:base="https://terminaladdict.com/php/networking/2020/09/11/cctv-streaming-to-a-website.html">&lt;p&gt;So I run a CCTV system based on the excellent open source &lt;a href=&quot;https://zoneminder.com/&quot; target=&quot;_blank&quot;&gt;Zoneminder&lt;/a&gt;, running on a pretty entry level ex-lease PC I bought from &lt;a href=&quot;https://www.pbtech.co.nz/category/computers/exleased/desktop-pcs&quot; target=&quot;_blank&quot;&gt;PBTech&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;What I want to do is embed one of the cameras into a web site.&lt;/p&gt;

&lt;p&gt;So my steps are going to be:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Setup a Zoneminder user for public access.&lt;/li&gt;
  &lt;li&gt;Write a small PHP proxy script.&lt;/li&gt;
  &lt;li&gt;Profit!&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;prerequisites&quot;&gt;Prerequisites&lt;/h2&gt;
&lt;p&gt;I’m not going to talk you through setting up a &lt;a href=&quot;https://www.debian.org/&quot; target=&quot;_blank&quot;&gt;Debian&lt;/a&gt; server.&lt;br /&gt;
Nor am I going to talk you through setting up a &lt;a href=&quot;https://zoneminder.com/&quot; target=&quot;_blank&quot;&gt;Zoneminder&lt;/a&gt; server on a &lt;a href=&quot;https://www.debian.org/&quot; target=&quot;_blank&quot;&gt;Debian&lt;/a&gt; server.&lt;/p&gt;

&lt;p&gt;I will assume that you have these things running.&lt;br /&gt;
I’ll also assume that you have the &lt;a href=&quot;https://zoneminder.com/&quot; target=&quot;_blank&quot;&gt;Zoneminder&lt;/a&gt; console running from a virtual sub directory in &lt;a href=&quot;https://httpd.apache.org/&quot; target=&quot;_blank&quot;&gt;Apache&lt;/a&gt; (in my case /zm/ ).&lt;/p&gt;

&lt;p&gt;But just in case, here’s a quick reminder of the &lt;a href=&quot;https://httpd.apache.org/&quot; target=&quot;_blank&quot;&gt;Apache&lt;/a&gt; config:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;# Remember to enable cgi mod (i.e. &quot;a2enmod cgi&quot;).&lt;/span&gt;
ScriptAlias /zm/cgi-bin &lt;span class=&quot;s2&quot;&gt;&quot;/usr/lib/zoneminder/cgi-bin&quot;&lt;/span&gt;
&amp;lt;Directory &lt;span class=&quot;s2&quot;&gt;&quot;/usr/lib/zoneminder/cgi-bin&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
    Options +ExecCGI &lt;span class=&quot;nt&quot;&gt;-MultiViews&lt;/span&gt; +SymLinksIfOwnerMatch
    AllowOverride All
    Require all granted
&amp;lt;/Directory&amp;gt;


&lt;span class=&quot;c&quot;&gt;# Order matters. This alias must come first.&lt;/span&gt;
Alias /zm/cache /var/cache/zoneminder/cache
&amp;lt;Directory /var/cache/zoneminder/cache&amp;gt;
    Options &lt;span class=&quot;nt&quot;&gt;-Indexes&lt;/span&gt; +FollowSymLinks
    AllowOverride None
    &amp;lt;IfModule mod_authz_core.c&amp;gt;
        &lt;span class=&quot;c&quot;&gt;# Apache 2.4&lt;/span&gt;
        Require all granted
    &amp;lt;/IfModule&amp;gt;
    &amp;lt;IfModule &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;mod_authz_core.c&amp;gt;
        &lt;span class=&quot;c&quot;&gt;# Apache 2.2&lt;/span&gt;
        Order deny,allow
        Allow from all
    &amp;lt;/IfModule&amp;gt;
&amp;lt;/Directory&amp;gt;

Alias /zm /usr/share/zoneminder/www
&amp;lt;Directory /usr/share/zoneminder/www&amp;gt;
  Options &lt;span class=&quot;nt&quot;&gt;-Indexes&lt;/span&gt; +FollowSymLinks
  &amp;lt;IfModule mod_dir.c&amp;gt;
    DirectoryIndex index.php
  &amp;lt;/IfModule&amp;gt;
&amp;lt;/Directory&amp;gt;

&lt;span class=&quot;c&quot;&gt;# For better visibility, the following directives have been migrated from the&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# default .htaccess files included with the CakePHP project.&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# Parameters not set here are inherited from the parent directive above.&lt;/span&gt;
&amp;lt;Directory &lt;span class=&quot;s2&quot;&gt;&quot;/usr/share/zoneminder/www/api&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
   RewriteEngine on
   RewriteRule ^&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;app/webroot/ &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;L]
   RewriteRule &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;.&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; app/webroot/&lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;L]
   RewriteBase /zm/api
&amp;lt;/Directory&amp;gt;

&amp;lt;Directory &lt;span class=&quot;s2&quot;&gt;&quot;/usr/share/zoneminder/www/api/app&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
   RewriteEngine on
   RewriteRule ^&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;webroot/ &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;L]
   RewriteRule &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;.&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; webroot/&lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;L]
   RewriteBase /zm/api
&amp;lt;/Directory&amp;gt;

&amp;lt;Directory &lt;span class=&quot;s2&quot;&gt;&quot;/usr/share/zoneminder/www/api/app/webroot&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
    RewriteEngine On
    RewriteCond %&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;REQUEST_FILENAME&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-d&lt;/span&gt;
    RewriteCond %&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;REQUEST_FILENAME&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt;
    RewriteRule ^ index.php &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;L]
    RewriteBase /zm/api
&amp;lt;/Directory&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;zoneminder-read-only-user&quot;&gt;Zoneminder read only user&lt;/h2&gt;
&lt;p&gt;Right, let’s start with a &lt;a href=&quot;https://zoneminder.com/&quot; target=&quot;_blank&quot;&gt;Zoneminder&lt;/a&gt; “read only” user.&lt;/p&gt;

&lt;p&gt;In your &lt;a href=&quot;https://zoneminder.com/&quot; target=&quot;_blank&quot;&gt;Zoneminder&lt;/a&gt; console, head to Options-&amp;gt;User, and smash that “ADD NEW USER” button.&lt;/p&gt;

&lt;p&gt;Pretty straight forward:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Username = YOURPUBLICUSER&lt;/li&gt;
  &lt;li&gt;Password = YOURPUBLICPASS
    &lt;ul&gt;
      &lt;li&gt;Confirm Password = YOURPUBLICPASS&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Language&lt;/li&gt;
  &lt;li&gt;Enabled = yes&lt;/li&gt;
  &lt;li&gt;Stream = View&lt;/li&gt;
  &lt;li&gt;Events = None&lt;/li&gt;
  &lt;li&gt;Control = None&lt;/li&gt;
  &lt;li&gt;Monitors = View&lt;/li&gt;
  &lt;li&gt;Groups = None&lt;/li&gt;
  &lt;li&gt;System = None&lt;/li&gt;
  &lt;li&gt;Max bandwidth = whatever you like&lt;/li&gt;
  &lt;li&gt;Restricted monitors = Select the Cameras you want available publicly.&lt;/li&gt;
  &lt;li&gt;API Enabled = No&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Save that bad boy.&lt;br /&gt;
That’s step 1 done 😊&lt;/p&gt;

&lt;h2 id=&quot;a-php-proxy-script&quot;&gt;A PHP Proxy script&lt;/h2&gt;

&lt;p&gt;So at this point you could just jam an image in any web site, using a specially crafted URL:&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http://YOUR-ZONEMINDER-CCTV-URL/zm/cgi-bin/nph-zms?monitor=1&amp;amp;user=YOURPUBLICUSER&amp;amp;pass=YOURPUBLICPASS&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;But, that kinda exposes, well, everything ! Your CCTV url, your readonly user and pass. I dunno, it just doesn’t seem right to me 🤣&lt;br /&gt;
So, I’m going to craft a small PHP proxy script which will hide this info from public view.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-php&quot; data-lang=&quot;php&quot;&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// storing this here just for future reference&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$streamurl&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;  &lt;span class=&quot;s2&quot;&gt;&quot;http://YOUR-ZONEMINDER-CCTV-URL/zm/cgi-bin/nph-zms?monitor=5&amp;amp;user=YOURPUBLICUSER&amp;amp;pass=YOURPUBLICPASS&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;nv&quot;&gt;$host&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;YOUR-ZONEMINDER-CCTV-URL&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$zmMonitor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;1&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$zmUser&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;YOURPUBLICUSER&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$zmPass&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;YOURPUBLICPASS&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$requestURI&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;/zm/cgi-bin/nph-zms&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;nv&quot;&gt;$getARGS&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$requestURI&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;?monitor=&quot;&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$zmMonitor&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&amp;amp;user=&quot;&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$zmUser&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&amp;amp;pass=&quot;&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$zmPass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;nb&quot;&gt;set_time_limit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$fp&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;fsockopen&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$host&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;80&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$errno&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$errstr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$fp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$errstr&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$errno&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;)&amp;lt;br&amp;gt;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;fputs&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$fp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;GET &quot;&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$getARGS&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot; HTTP/1.0&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\r\n\r\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$str&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;trim&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;fgets&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$fp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4096&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)))&lt;/span&gt;
       &lt;span class=&quot;nb&quot;&gt;header&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;fpassthru&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$fp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;fclose&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$fp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;That’s it; save that PHP script as .. I dunno .. zoneminder_stream.php ?&lt;/p&gt;

&lt;h2 id=&quot;embed-in-html&quot;&gt;Embed in HTML&lt;/h2&gt;
&lt;p&gt;Here’s the fun bit .. simple HTML !&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;img src=&quot;/path/to/zoneminder_stream.php&quot; alt=&quot;my stream&quot; /&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and here is the working result:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://terminaladdict.com/assets/images/posts/thumbnails/zoneminder_stream.jpg&quot; alt=&quot;zoneminder_stream.jpg&quot; rel=&quot;lightbox&quot; class=&quot;shadow-lg rounded&quot; /&gt;&lt;/p&gt;

&lt;p&gt;*note: this is a screenshot of my working camera&lt;/p&gt;</content><author><name>paul</name></author><category term="php" /><category term="networking" /><summary type="html">So I run a CCTV system based on the excellent open source Zoneminder, running on a pretty entry level ex-lease PC I bought from PBTech.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://terminaladdict.com/no-image.png" /><media:content medium="image" url="https://terminaladdict.com/no-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Lets Encrypt Setup On Debian</title><link href="https://terminaladdict.com/linux/networking/bash/2020/02/13/LetsEncrypt.html" rel="alternate" type="text/html" title="Lets Encrypt Setup On Debian" /><published>2020-02-13T00:00:00+13:00</published><updated>2020-02-13T00:00:00+13:00</updated><id>https://terminaladdict.com/linux/networking/bash/2020/02/13/LetsEncrypt</id><content type="html" xml:base="https://terminaladdict.com/linux/networking/bash/2020/02/13/LetsEncrypt.html">&lt;p&gt;So in a few of my posts I’ve mentioned &lt;a href=&quot;https://letsencrypt.org&quot; target=&quot;_blank&quot;&gt;Let’s Encrypt&lt;/a&gt; as a method of getting SSL Certificates for free.&lt;br /&gt;
In this post I’ll explain how I set up &lt;a href=&quot;https://www.nginx.com&quot; target=&quot;_blank&quot;&gt;Nginx&lt;/a&gt; to use Let’s Encrypt SSL certs.&lt;/p&gt;

&lt;h2 id=&quot;initial-install-and-setup&quot;&gt;Initial install and setup&lt;/h2&gt;
&lt;p&gt;I decide a while ago that &lt;a href=&quot;https://github.com/dehydrated-io/dehydrated&quot; target=&quot;_blank&quot;&gt;Dehydrated&lt;/a&gt; would be the script I would use to manage my SSL certs. And conveniently for me there is a Debian package. So let’s install it.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;aptitude install dehydrated&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This creates a config directory in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/dehydrated&lt;/code&gt; and stores all your certs in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/var/lib/dehydrated/certs&lt;/code&gt;.&lt;br /&gt;
Great, let’s config it.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;#############################################################&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# This is the main config file for dehydrated               #&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#                                                           #&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# This is the default configuration for the Debian package. #&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# To see a more comprehensive example, see                  #&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# /usr/share/doc/dehydrated/examples/config                 #&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#                                                           #&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# For details please read:                                  #&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# /usr/share/doc/dehydrated/README.Debian                   #&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#############################################################&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;CONFIG_D&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/etc/dehydrated/conf.d
&lt;span class=&quot;nv&quot;&gt;BASEDIR&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/var/lib/dehydrated
&lt;span class=&quot;nv&quot;&gt;WELLKNOWN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;/var/www/dehydrated&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;DOMAINS_TXT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;/etc/dehydrated/domains.txt&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;CONTACT_EMAIL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;paul@domain.com
&lt;span class=&quot;nv&quot;&gt;HOOK&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/etc/dehydrated/hook.sh&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Ok, so there’s a few things in this config we’re going to have to create&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;the directory /var/www/dehydrated&lt;/li&gt;
  &lt;li&gt;the file /etc/dehydrated/domains.txt&lt;/li&gt;
  &lt;li&gt;the hook file /etc/dehydrated/hook.sh&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So let’s do that:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mkdir /var/www/dehydrated &amp;amp;&amp;amp; chown www-data:www-data /var/www/dehydrated&lt;/code&gt;&lt;br /&gt;
Pretty simple so far.&lt;/p&gt;

&lt;p&gt;The domains file&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;terminaladdict.com www.terminaladdict.com myother-subdomain.terminaladdict.com&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Let’s Encrypt creates one certificate “per line” i.e. it creates one certificate that covers the domain terminaladdict.com, and the sub domains.&lt;br /&gt;
The sub domains must all exist in DNS, and all exist in Nginx.&lt;/p&gt;

&lt;h2 id=&quot;the-hook-file&quot;&gt;The Hook File&lt;/h2&gt;
&lt;p&gt;I got this hook file from &lt;a href=&quot;https://www.aaflalo.me/2016/09/dehydrated-bash-client-lets-encrypt/&quot; target=&quot;_blank&quot;&gt;Antoine Aflalo&lt;/a&gt; &lt;br /&gt;
Here it is:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;deploy_challenge&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
     &lt;span class=&quot;nb&quot;&gt;local &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;DOMAIN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;TOKEN_FILENAME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;TOKEN_VALUE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
clean_challenge&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
 &lt;span class=&quot;nb&quot;&gt;local &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;DOMAIN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;TOKEN_FILENAME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;TOKEN_VALUE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
deploy_cert&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
 &lt;span class=&quot;nb&quot;&gt;local &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;DOMAIN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;KEYFILE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;CERTFILE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;FULLCHAINFILE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;CHAINFILE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;TIMESTAMP&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;

 systemctl reload nginx
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
unchanged_cert&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
 &lt;span class=&quot;nb&quot;&gt;local &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;DOMAIN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;KEYFILE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;CERTFILE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;FULLCHAINFILE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;CHAINFILE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
invalid_challenge&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
 &lt;span class=&quot;nb&quot;&gt;local &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;DOMAIN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;RESPONSE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
request_failure&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
 &lt;span class=&quot;nb&quot;&gt;local &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;STATUSCODE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;REASON&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;REQTYPE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
exit_hook&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
 :
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;HANDLER&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;shift
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[[&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;HANDLER&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;~ ^&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;deploy_challenge|clean_challenge|deploy_cert|unchanged_cert|invalid_challenge|request_failure|exit_hook&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt;
 &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$HANDLER&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$@&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;fi&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;nginx-config&quot;&gt;Nginx Config&lt;/h2&gt;
&lt;p&gt;Setting up Nginx is pretty straight forward, you need a “.well-known” directive:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-nginx&quot; data-lang=&quot;nginx&quot;&gt;&lt;span class=&quot;k&quot;&gt;server&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;listen&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;80&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;listen&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;[::]:80&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kn&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/.well-known/acme-challenge&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;alias&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/var/www/dehydrated&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;root&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/var/www/html/terminaladdict.com&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kn&quot;&gt;server_name&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;terminaladdict.com&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;www.terminaladdict.com&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;that’s our entire config for port 80 (HTTP).&lt;/p&gt;

&lt;p&gt;For the SSL port 443 (HTTPS) config:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-nginx&quot; data-lang=&quot;nginx&quot;&gt;&lt;span class=&quot;k&quot;&gt;server&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;kn&quot;&gt;listen&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;443&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;ssl&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;http2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;kn&quot;&gt;listen&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;[::]:443&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;ssl&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;http2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kn&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/.well-known/acme-challenge&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;kn&quot;&gt;alias&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/var/www/dehydrated&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;ssl_certificate&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/var/lib/dehydrated/certs/terminaladdict.com/fullchain.pem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;ssl_certificate_key&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/var/lib/dehydrated/certs/terminaladdict.com/privkey.pem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

	&lt;span class=&quot;c1&quot;&gt;# enables all versions of TLS, but not SSLv2 or 3 which are weak and now deprecated.&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;ssl_protocols&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;TLSv1&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;TLSv1.1&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;TLSv1.2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;# disables all weak ciphers&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;ssl_ciphers&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'AES128+EECDH:AES128+EDH'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kn&quot;&gt;ssl_prefer_server_ciphers&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kn&quot;&gt;root&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/var/www/html/terminaladdict.com&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;client_max_body_size&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100m&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kn&quot;&gt;index&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;index.html&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kn&quot;&gt;server_name&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;terminaladdict.com&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;access_log&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/var/log/nginx/terminaladdict.com-access.log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;error_log&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/var/log/nginx/terminaladdict.com-error.log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kn&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;try_files&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$uri&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$uri&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;index.html&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;add_header&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Service-Worker-Allowed&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;error_page&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;404&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;404&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/404.html&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kn&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/manifest.json&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;default_type&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;application/x-web-app-manifest&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;+json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;kn&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;~&lt;/span&gt; &lt;span class=&quot;sr&quot;&gt;/\.ht&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;deny&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;all&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;# ESSENTIAL : no favicon logs&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/favicon.ico&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;log_not_found&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;off&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;access_log&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;off&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;# ESSENTIAL : robots.txt&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/robots.txt&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;allow&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;all&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;log_not_found&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;off&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;access_log&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;off&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;sw&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;.js&lt;/span&gt;$ &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;expires&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;-1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;# PERFORMANCE : Set expires headers for static files and turn off logging.&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;^.+&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;.(js|css|swf|xml|txt|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)&lt;/span&gt;$ &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;kn&quot;&gt;access_log&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;off&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;log_not_found&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;off&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;expires&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;30d&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;You won’t be able to restart Nginx yet, as you don’t have the certs.&lt;br /&gt;
What I do is comment out the two lines that point to the certs, reload Nginx, then uncomment them once I have the certs.&lt;/p&gt;

&lt;h2 id=&quot;getting-the-cert&quot;&gt;Getting the cert&lt;/h2&gt;
&lt;p&gt;Here we go:&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dehydrated -fc -c&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You should see output like this:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;Processing terminaladdict.com with alternative names: www.terminaladdict.com
 + Checking domain name&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;s&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; of existing cert... unchanged.
 + Checking expire &lt;span class=&quot;nb&quot;&gt;date &lt;/span&gt;of existing cert...
 + Valid till Mar 12 12:05:56 2020 GMT Certificate will expire
&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;Less than 30 days&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt; Renewing!
 + Signing domains...
 + Generating private key...
 + Generating signing request...
 + Requesting new certificate order from CA...
 + Received 2 authorizations URLs from the CA
 + Handling authorization &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;terminaladdict.com
 + Handling authorization &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;www.terminaladdict.com
 + 2 pending challenge&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;s&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
 + Deploying challenge tokens...
 + Responding to challenge &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;terminaladdict.com authorization...
 + Challenge is valid!
 + Responding to challenge &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;www.terminaladdict.com authorization...
 + Challenge is valid!
 + Cleaning challenge tokens...
 + Requesting certificate...
 + Checking certificate...
 + Done!
 + Creating fullchain.pem...
 + Done!&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;That’s it! go and load your website in a browser and check out your new SSL certificate!&lt;/p&gt;

&lt;h2 id=&quot;automating&quot;&gt;Automating&lt;/h2&gt;
&lt;p&gt;Hello cron:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# lets encrypt
5 2     * * 6   root    /usr/bin/dehydrated -fc -c &amp;gt; /dev/null 2&amp;gt;&amp;amp;1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>paul</name></author><category term="linux" /><category term="networking" /><category term="bash" /><summary type="html">So in a few of my posts I’ve mentioned Let’s Encrypt as a method of getting SSL Certificates for free. In this post I’ll explain how I set up Nginx to use Let’s Encrypt SSL certs.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://terminaladdict.com/no-image.png" /><media:content medium="image" url="https://terminaladdict.com/no-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Dns Over Https Or (doh) Bind9 And Nginx</title><link href="https://terminaladdict.com/networking/linux/2019/09/13/DoH.html" rel="alternate" type="text/html" title="Dns Over Https Or (doh) Bind9 And Nginx" /><published>2019-09-13T00:00:00+12:00</published><updated>2019-09-13T00:00:00+12:00</updated><id>https://terminaladdict.com/networking/linux/2019/09/13/DoH</id><content type="html" xml:base="https://terminaladdict.com/networking/linux/2019/09/13/DoH.html">&lt;p&gt;So in a litte while Google Chrome is going to enable DNS over HTTPs, and Firefox has already enabled it, by default!&lt;br /&gt;
So I think to myself “myself, do you want cloudflare watching all your DNS queries?” - nope is the the answer!&lt;br /&gt;
Right, so I’ll build my own DNS over HTTPs (DoH) server.&lt;/p&gt;

&lt;p&gt;So what I’m going to do is:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Setup nginx to act as a front end proxy.&lt;/li&gt;
  &lt;li&gt;Build and install a go package called &lt;a href=&quot;https://github.com/m13253/dns-over-https&quot; target=&quot;_blank&quot;&gt;doh-server&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Check that it all works 👨‍💻&lt;/li&gt;
  &lt;li&gt;Configure my browser&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This doc assumes you have a working DNS server (I use bind9), and you can sort your own SSL certs for nginx.&lt;br /&gt;
It also assumes you know your way around a command line 🤪&lt;/p&gt;

&lt;h2 id=&quot;set-up-nginx&quot;&gt;Set up nginx&lt;/h2&gt;

&lt;p&gt;So I’m not going to talk you through how to install nginx, or get it running, that is beyond the scope of this doc.&lt;br /&gt;
I’m also not going to tell you how to setup &lt;a href=&quot;https://letsencrypt.org/&quot; target=&quot;_blank&quot;&gt;Let’s Encrypt&lt;/a&gt;, that is also outside the scope of this doc.&lt;/p&gt;

&lt;p&gt;So let’s get straight into the config:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-nginx&quot; data-lang=&quot;nginx&quot;&gt;&lt;span class=&quot;k&quot;&gt;upstream&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;dns-backend&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;server&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;127.0.0.1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8053&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;keepalive&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;server&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;listen&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;80&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;listen&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;[::]:80&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kn&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/.well-known/acme-challenge&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;alias&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/var/www/dehydrated&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;root&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/var/www/html&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kn&quot;&gt;server_name&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;ns1.example.com&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;301&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;https://&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$host&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;server&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;listen&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;443&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;ssl&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;http2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;listen&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;[::]:443&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;ssl&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;http2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kn&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/.well-known/acme-challenge&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;kn&quot;&gt;alias&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/var/www/dehydrated&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;ssl_certificate&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/etc/dehydrated/certs/ns1.example.com/fullchain.pem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;ssl_certificate_key&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/etc/dehydrated/certs/ns1.example.com/privkey.pem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;# enables all versions of TLS, but not SSLv2 or 3 which are weak and now deprecated.&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;ssl_protocols&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;TLSv1&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;TLSv1.1&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;TLSv1.2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;# disables all weak ciphers&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;ssl_ciphers&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'AES128+EECDH:AES128+EDH'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kn&quot;&gt;ssl_prefer_server_ciphers&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kn&quot;&gt;root&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/var/www/html&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kn&quot;&gt;index&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;index.html&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;index.htm&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;index.nginx-debian.html&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kn&quot;&gt;server_name&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;ns1.example.com&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;access_log&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/var/log/nginx/ns1.example.com-access.log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;error_log&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/var/log/nginx/ns1.example.com-error.log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kn&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/dns-query&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;proxy_set_header&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;X-Real-IP&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$remote_addr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;proxy_set_header&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;X-Forwarded-For&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$proxy_add_x_forwarded_for&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;proxy_set_header&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Host&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$http_host&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;proxy_set_header&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;X-NginX-Proxy&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;proxy_set_header&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Connection&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;proxy_http_version&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;.1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;proxy_set_header&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Upgrade&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$http_upgrade&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;proxy_redirect&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;off&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;proxy_set_header&lt;/span&gt;        &lt;span class=&quot;s&quot;&gt;X-Forwarded-Proto&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$scheme&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;proxy_read_timeout&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;86400&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;proxy_pass&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;http://dns-backend/dns-query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;So let me talk you through the config:&lt;br /&gt;
I start by creating a config that points to our, not yet installed, doh-server. That server is going to be running on port 8053:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-nginx&quot; data-lang=&quot;nginx&quot;&gt;&lt;span class=&quot;k&quot;&gt;upstream&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;dns-backend&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;server&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;127.0.0.1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8053&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;keepalive&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Next I’ve got a server block for port 80 (non-secure / non https).&lt;br /&gt;
It has some config for my Let’s Encrypt SSL cert bot (dehydrated), and redirects everthing to the SSL version of the website (return 301):&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-nginx&quot; data-lang=&quot;nginx&quot;&gt;&lt;span class=&quot;k&quot;&gt;server&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;listen&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;80&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;listen&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;[::]:80&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kn&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/.well-known/acme-challenge&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;alias&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/var/www/dehydrated&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;root&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/var/www/html&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kn&quot;&gt;server_name&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;ns1.example.com&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;301&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;https://&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$host&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;and lastly, the SSL version config, includng the reverse proxy bit which I will repeat here (because it is the important bit):&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-nginx&quot; data-lang=&quot;nginx&quot;&gt;&lt;span class=&quot;k&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/dns-query&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;proxy_set_header&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;X-Real-IP&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$remote_addr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;proxy_set_header&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;X-Forwarded-For&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$proxy_add_x_forwarded_for&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;proxy_set_header&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Host&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$http_host&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;proxy_set_header&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;X-NginX-Proxy&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;proxy_set_header&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Connection&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;proxy_http_version&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;.1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;proxy_set_header&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Upgrade&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$http_upgrade&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;proxy_redirect&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;off&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;proxy_set_header&lt;/span&gt;        &lt;span class=&quot;s&quot;&gt;X-Forwarded-Proto&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$scheme&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;proxy_read_timeout&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;86400&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;proxy_pass&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;http://dns-backend/dns-query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;So assuming that you have your SSL certs sorted, and your nginx config is all good you should be able to start nginx 🥰&lt;/p&gt;

&lt;h2 id=&quot;install-doh-server&quot;&gt;Install doh-server&lt;/h2&gt;

&lt;p&gt;so you’ll need some build packages, so let’s install some build tools:&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;aptitude install curl software-properties-common build-essential git&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And you’re going to need to get your golang environment setup:&lt;br /&gt;
&lt;a href=&quot;/linux/bash/golang/2019/09/10/Install-Golang-on-Debian-Buster.html&quot;&gt;Install Go on Debian Buster&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;now let’s install the DoH server:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;git clone git@github.com:m13253/dns-over-https.git
&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;dns-over-https/
make
make &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Now let’s config the DoH server:&lt;br /&gt;
The DoH server has a config in /etc/dns-over-https/doh-server.conf&lt;br /&gt;
You want to change the upstream to use 127.0.0.1:53 and that’s about it, here’s what I’ve got:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-conf&quot; data-lang=&quot;conf&quot;&gt;&lt;span class=&quot;n&quot;&gt;listen&lt;/span&gt; = [
    &lt;span class=&quot;s2&quot;&gt;&quot;127.0.0.1:8053&quot;&lt;/span&gt;,
    &lt;span class=&quot;s2&quot;&gt;&quot;[::1]:8053&quot;&lt;/span&gt;
]
&lt;span class=&quot;n&quot;&gt;local_addr&lt;/span&gt; = &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;cert&lt;/span&gt; = &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;key&lt;/span&gt; = &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt; = &lt;span class=&quot;s2&quot;&gt;&quot;/dns-query&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;upstream&lt;/span&gt; = [
	&lt;span class=&quot;s2&quot;&gt;&quot;127.0.0.1:53&quot;&lt;/span&gt;
]
&lt;span class=&quot;n&quot;&gt;timeout&lt;/span&gt; = &lt;span class=&quot;m&quot;&gt;10&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;tries&lt;/span&gt; = &lt;span class=&quot;m&quot;&gt;3&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;tcp_only&lt;/span&gt; = &lt;span class=&quot;n&quot;&gt;false&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;verbose&lt;/span&gt; = &lt;span class=&quot;n&quot;&gt;false&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;log_guessed_client_ip&lt;/span&gt; = &lt;span class=&quot;n&quot;&gt;false&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Once you’ve got that saved you can restart the DoH server with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;systemctl restart doh-server&lt;/code&gt;&lt;/p&gt;

&lt;h2 id=&quot;testing-the-install&quot;&gt;Testing the install&lt;/h2&gt;
&lt;p&gt;So let’s recap:&lt;br /&gt;
We have:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Configured nginx and got it running nicely, forwarding DoH requests&lt;/li&gt;
  &lt;li&gt;Installed a DoH server&lt;/li&gt;
  &lt;li&gt;We already had a DNS resolver installed and running, right? 🧐&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now let’s do some testing.&lt;/p&gt;

&lt;p&gt;The DoH server returns JSON, so you can just test in your browser:&lt;br /&gt;
https://ns1.example.com/dns-query?name=example.org&amp;amp;type=A&lt;/p&gt;

&lt;p&gt;Or, since you’re already working in a terminal (and this website &lt;em&gt;is&lt;/em&gt; called Terminal Addict 😇)&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;curl &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;https://ns1.example.com/dns-query?name=example.org&amp;amp;type=A&quot;&lt;/span&gt; | python &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; json.tool&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;You should get a JSON response like the following:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-json&quot; data-lang=&quot;json&quot;&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;AD&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;Answer&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;Expires&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Thu, 12 Sep 2019 22:59:07 UTC&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;TTL&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;7090&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;93.184.216.34&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;example.org.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;Expires&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Thu, 12 Sep 2019 22:59:07 UTC&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;TTL&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;7090&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;A 8 2 86400 20190921055451 20190831145703 31036 example.org. r4fWzdiYS7Px0qXX+7cHtPsj2a3lFhmeM4OXvOsDd2WorpP3Na/FupUFozdp2ao7xyguW+tZSJEI01dKuMt5MDfmJR4cN2n+IiRMvLvQuG60SnQNRBmOTTwca79GNTv5To8rxU5kSixH1liyho2/c/hvIqZKajHs6Bxr460A/RM=&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;example.org.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;46&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;Authority&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;Expires&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Thu, 12 Sep 2019 21:18:35 UTC&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;TTL&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1058&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;l.root-servers.net.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;Expires&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Thu, 12 Sep 2019 21:18:35 UTC&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;TTL&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1058&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;j.root-servers.net.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;Expires&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Thu, 12 Sep 2019 21:18:35 UTC&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;TTL&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1058&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;h.root-servers.net.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;Expires&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Thu, 12 Sep 2019 21:18:35 UTC&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;TTL&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1058&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;e.root-servers.net.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;Expires&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Thu, 12 Sep 2019 21:18:35 UTC&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;TTL&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1058&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;f.root-servers.net.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;Expires&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Thu, 12 Sep 2019 21:18:35 UTC&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;TTL&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1058&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;g.root-servers.net.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;Expires&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Thu, 12 Sep 2019 21:18:35 UTC&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;TTL&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1058&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;k.root-servers.net.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;Expires&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Thu, 12 Sep 2019 21:18:35 UTC&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;TTL&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1058&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;b.root-servers.net.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;Expires&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Thu, 12 Sep 2019 21:18:35 UTC&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;TTL&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1058&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;d.root-servers.net.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;Expires&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Thu, 12 Sep 2019 21:18:35 UTC&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;TTL&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1058&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;i.root-servers.net.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;Expires&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Thu, 12 Sep 2019 21:18:35 UTC&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;TTL&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1058&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;a.root-servers.net.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;Expires&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Thu, 12 Sep 2019 21:18:35 UTC&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;TTL&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1058&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;m.root-servers.net.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;Expires&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Thu, 12 Sep 2019 21:18:35 UTC&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;TTL&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1058&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;c.root-servers.net.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;Expires&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Thu, 12 Sep 2019 21:18:35 UTC&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;TTL&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1058&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;NS 8 0 518400 20190925170000 20190912160000 59944 . E7Vt9bijsTA8J2m5mcI9mc7uyk2PAbjtuDS4zGFaDVpVP4UyFFPYrttCA5CrXFurVN+Qf0nzB31pLzPfrgnY2xqe2S0Pm7Qq+t7rCp/Q1mNp3JbZG4fYxRXoz9uz4zSCaXDJ9WP4zrWrYd++ZGuUs4DXawg9qo0QhX5KRnXehDM9WkjY3JM61tw8CN5KS1ODov7Nw5qZI2uJ69npPnElm163cePQgZTkoGA8AO5vgmgHVbZZqQ3GkxNa8lzHNH/G66xEvPXLe03h6QptCHcOugU6SwCzmxbt2hQnvbQXZk4eGz330CmwlwVPEAKP3VwWsruEkU+LWBIohDg/0Yk6Dg==&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;46&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;CD&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;Question&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;example.org.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;type&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;RA&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;RD&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;Status&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;TC&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;edns_client_subnet&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;103.123.164.0/0&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;configure-your-browser&quot;&gt;Configure your browser&lt;/h2&gt;

&lt;p&gt;Well in Firefox this is pretty easy.&lt;br /&gt;
Search your preferences / settings in Firefox for DNS.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://terminaladdict.com/assets/images/posts/thumbnails/FF-DoH-settings.png&quot; alt=&quot;FF-DoH-settings.png&quot; rel=&quot;lightbox&quot; class=&quot;shadow-lg rounded&quot; /&gt;&lt;/p&gt;

&lt;p&gt;In Google Chrome the setting will be released in version 78 I’m told, I guess I’ll keep an eye out 🙃&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;So, maybe you’re super sentive about people spying on you, maybe you like playing with new gadgets / tech. Who knows.&lt;br /&gt;
But, I certainly don’t trust cloudflare enough to be giving them my browser DNS queries!&lt;/p&gt;

&lt;p&gt;So we’ve now got DNS over HTTPs to use, and we own all our own history / data 👍&lt;/p&gt;</content><author><name>paul</name></author><category term="networking" /><category term="linux" /><summary type="html">So in a litte while Google Chrome is going to enable DNS over HTTPs, and Firefox has already enabled it, by default! So I think to myself “myself, do you want cloudflare watching all your DNS queries?” - nope is the the answer! Right, so I’ll build my own DNS over HTTPs (DoH) server.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://terminaladdict.com/no-image.png" /><media:content medium="image" url="https://terminaladdict.com/no-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Install Golang On Debian Buster</title><link href="https://terminaladdict.com/linux/bash/golang/2019/09/10/Install-Golang-on-Debian-Buster.html" rel="alternate" type="text/html" title="Install Golang On Debian Buster" /><published>2019-09-10T00:00:00+12:00</published><updated>2019-09-10T00:00:00+12:00</updated><id>https://terminaladdict.com/linux/bash/golang/2019/09/10/Install-Golang-on-Debian-Buster</id><content type="html" xml:base="https://terminaladdict.com/linux/bash/golang/2019/09/10/Install-Golang-on-Debian-Buster.html">&lt;p&gt;&lt;a href=&quot;https://golang.org/&quot; target=&quot;_blank&quot;&gt;Golang, or just simply Go&lt;/a&gt; is an open source programming language that makes it easy to build simple, reliable, and efficient software.&lt;br /&gt;
This is way easier than you think !!&lt;/p&gt;

&lt;h2 id=&quot;step-1---download&quot;&gt;Step 1 - download&lt;/h2&gt;
&lt;p&gt;Firstly, let make sure our system is up-to-date&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo apt update &amp;amp;&amp;amp; sudo apt upgrade&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;No let’s download the go package:&lt;br /&gt;
Go to &lt;a href=&quot;https://golang.org/dl/&quot;&gt;Go’s download page&lt;/a&gt; and grab a link for the latest version.&lt;br /&gt;
The version when I wrote this wee blog was go1.13. &lt;br /&gt;
Got the link? sweet! let’s download it:&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wget https://dl.google.com/go/go1.13.linux-amd64.tar.gz&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now let’s untar it&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tar xvfz go1.13.linux-amd64.tar.gz&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And move it to an appropriate place (like /usr/local maybe?)&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo mv go /usr/local/go&lt;/code&gt;&lt;/p&gt;

&lt;h2 id=&quot;step-2---setup-your-environment&quot;&gt;Step 2 - setup your environment&lt;/h2&gt;

&lt;p&gt;We’re going to add a few environment variables in our .bashrc, and add to our $PATH.&lt;br /&gt;
so let’s do that&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;EOF&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;' &amp;gt;&amp;gt; ~/.bashrc
export GOROOT=/usr/local/go
export GOPATH=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$HOME&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;/goProjects
export PATH=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$GOPATH&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;/bin:&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$GOROOT&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;/bin:&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$PATH&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;

EOF&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;and then create our goProjects directory:&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mkdir ~/goProjects &lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and finally, let’s reload our environment:&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;source ~/.bashrc &lt;/code&gt;&lt;/p&gt;

&lt;p&gt;What we’ve done is:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Told our bash environment where to find go&lt;/li&gt;
  &lt;li&gt;Told our bash environment where our working directory is (~/goProjects)&lt;/li&gt;
  &lt;li&gt;added two directories to our $PATH&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;step-3---verify-your-install&quot;&gt;Step 3 - verify your install&lt;/h2&gt;

&lt;p&gt;Here comes the easy bit, let’s check our installed go version:&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;go version &lt;/code&gt;&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;go version go1.13 linux/amd64&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;and let’s check our go environment&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;go env&lt;/code&gt;&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;GO111MODULE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;GOARCH&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;amd64&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;GOBIN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;GOCACHE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;/home/paul/.cache/go-build&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;GOENV&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;/home/paul/.config/go/env&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;GOEXE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;GOFLAGS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;GOHOSTARCH&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;amd64&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;GOHOSTOS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;linux&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;GONOPROXY&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;GONOSUMDB&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;GOOS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;linux&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;GOPATH&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;/home/paul/goProjects&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;GOPRIVATE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;GOPROXY&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;https://proxy.golang.org,direct&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;GOROOT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;/usr/local/go&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;GOSUMDB&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;sum.golang.org&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;GOTMPDIR&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;GOTOOLDIR&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;/usr/local/go/pkg/tool/linux_amd64&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;GCCGO&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;gccgo&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;AR&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ar&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;CC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;gcc&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;CXX&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;g++&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;CGO_ENABLED&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;1&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;GOMOD&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;CGO_CFLAGS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;-g -O2&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;CGO_CPPFLAGS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;CGO_CXXFLAGS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;-g -O2&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;CGO_FFLAGS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;-g -O2&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;CGO_LDFLAGS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;-g -O2&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;PKG_CONFIG&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;pkg-config&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;GOGCCFLAGS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build934234536=/tmp/go-build -gno-record-gcc-switches&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Simple eh? 👍&lt;/p&gt;

&lt;p&gt;no get “go-ing” 😂&lt;/p&gt;</content><author><name>paul</name></author><category term="linux" /><category term="bash" /><category term="golang" /><summary type="html">Golang, or just simply Go is an open source programming language that makes it easy to build simple, reliable, and efficient software. This is way easier than you think !!</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://terminaladdict.com/no-image.png" /><media:content medium="image" url="https://terminaladdict.com/no-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Linux Streaming Webcams</title><link href="https://terminaladdict.com/linux/2019/03/11/linux-streaming-webcams.html" rel="alternate" type="text/html" title="Linux Streaming Webcams" /><published>2019-03-11T00:00:00+13:00</published><updated>2019-03-11T00:00:00+13:00</updated><id>https://terminaladdict.com/linux/2019/03/11/linux-streaming-webcams</id><content type="html" xml:base="https://terminaladdict.com/linux/2019/03/11/linux-streaming-webcams.html">&lt;p&gt;In this little snippet / howto I’m going to show how I got a regular Logitech webcam streaming over the internet.&lt;/p&gt;

&lt;p&gt;So let’s start with the problem:&lt;br /&gt;
I have a fishtank, I wanted to create a “fish cam” :)&lt;/p&gt;

&lt;h2 id=&quot;step-1---hardware&quot;&gt;Step 1 - Hardware&lt;/h2&gt;

&lt;p&gt;So I have a regular &lt;a href=&quot;https://support.logitech.com/en_us/product/hd-pro-webcam-c910&quot; target=&quot;_blank&quot;&gt;Logitech HD Webcam C910&lt;/a&gt;, and a standard &lt;a href=&quot;https://www.debian.org/&quot; target=&quot;_blank&quot;&gt;Debian stretch&lt;/a&gt; sitting on a PC next to my fishtank.&lt;/p&gt;

&lt;p&gt;Pretty straight forward so far, I do have contrib and non-free repos enabled&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;deb http://deb.debian.org/debian/ stretch main non-free contrib
deb-src http://deb.debian.org/debian/ stretch main non-free contrib

deb http://security.debian.org/debian-security stretch/updates main contrib non-free
deb-src http://security.debian.org/debian-security stretch/updates main contrib non-free&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;step-2---the-streaming-software&quot;&gt;Step 2 - The streaming software&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Motion&lt;/strong&gt; - &lt;a href=&quot;https://motion-project.github.io/&quot; target=&quot;_blank&quot;&gt;link&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here’s a wee quote from the website&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Motion is a highly configurable program that monitors video signals from many types of cameras.
Set it up to monitor your security cameras, watch birds, check in on your pet, create timelapse videos and more.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Wow, that’s what I want to do - check in on my pets :)&lt;/p&gt;

&lt;p&gt;So let’s install it:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;aptitude &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;motion&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;TADA !!!!&lt;/p&gt;

&lt;p&gt;No let’s configure it.&lt;/p&gt;

&lt;p&gt;I don’t want to keep images, I just want to stream, so the steps I need to do are:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Create a conf directory in my home directory&lt;/li&gt;
  &lt;li&gt;Create a config file in the created config directory&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So let’s create a directory by doing&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mkdir ~/.motion&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;No let’s create a config file by doing&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vi ~/.motion/motion.conf&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Note: probably don’t do this as user root&lt;/p&gt;

&lt;p&gt;Let’s look at my config&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;stream_port 9091
stream_localhost off
webcontrol_localhost off
webcontrol_port 9092
minimum_motion_frames 1
output_pictures off
quality 100
stream_quality 100&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Basically, the needed bits are &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;stream_port 9091&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;stream_localhost off&lt;/code&gt;, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;output_pictures off&lt;/code&gt;.&lt;br /&gt;
This sets the tcp port you want to use, disables “localhost” only, and turns off saving images.&lt;/p&gt;

&lt;h2 id=&quot;run-the-server&quot;&gt;Run the server&lt;/h2&gt;

&lt;p&gt;Here’s the fun bit.&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;motion&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;That’s it, you have a streaming server up and running. You can view it by open a browser and going to http://your.ip.address:9091/&lt;/p&gt;

&lt;h2 id=&quot;wrapping-up&quot;&gt;Wrapping up&lt;/h2&gt;

&lt;p&gt;So to get this all up and running (and public if you want that) you have to open a tcp port on your firewall.&lt;br /&gt;
I use Mikrotik, so here is what I do:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;/ip firewall nat
&lt;span class=&quot;nv&quot;&gt;chain&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;dstnat &lt;span class=&quot;nv&quot;&gt;action&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;dst-nat to-addresses&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;10.0.0.2 to-ports&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;9091 &lt;span class=&quot;nv&quot;&gt;protocol&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;tcp &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-interface&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;ether1 dst-port&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;9091 &lt;span class=&quot;nv&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;no log-prefix&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;and of course you want to see it running, so here’s a link:&lt;br /&gt;
&lt;a href=&quot;https://www.loudas.com/family/general-life/2019/03/11/Linux-Streaming-webcam.html&quot; target=&quot;_blank&quot;&gt;Fishcam (webcam streaming)&lt;/a&gt;&lt;br /&gt;
A wee note: I built a small php proxy script that looks like this:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-php&quot; data-lang=&quot;php&quot;&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;set_time_limit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$fp&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;fsockopen&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;my.public.ip&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;9091&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$errno&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$errstr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$fp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$errstr&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$errno&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;)&amp;lt;br&amp;gt;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;fputs&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$fp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;GET / HTTP/1.0&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\r\n\r\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$str&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;trim&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;fgets&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$fp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4096&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)))&lt;/span&gt;
       &lt;span class=&quot;nb&quot;&gt;header&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;fpassthru&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$fp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;fclose&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$fp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;</content><author><name>paul</name></author><category term="linux" /><summary type="html">In this little snippet / howto I’m going to show how I got a regular Logitech webcam streaming over the internet.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://terminaladdict.com/no-image.png" /><media:content medium="image" url="https://terminaladdict.com/no-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Web Development And Validation</title><link href="https://terminaladdict.com/development/2019/02/25/Web-Development-and-Validation.html" rel="alternate" type="text/html" title="Web Development And Validation" /><published>2019-02-25T00:00:00+13:00</published><updated>2019-02-25T00:00:00+13:00</updated><id>https://terminaladdict.com/development/2019/02/25/Web-Development-and-Validation</id><content type="html" xml:base="https://terminaladdict.com/development/2019/02/25/Web-Development-and-Validation.html">&lt;p&gt;So I do a bit of web development, and of course have developed all 3 my own sites numerous times. I’m currently using &lt;a href=&quot;https://jekyllrb.com/&quot; target=&quot;_blank&quot;&gt;Jekyll&lt;/a&gt; for my own sites (&lt;a href=&quot;https://terminaladdict.com&quot; target=&quot;_blank&quot;&gt;TerminalAddict.com&lt;/a&gt;, &lt;a href=&quot;https://www.loudas.com&quot; target=&quot;_blank&quot;&gt;Loudas.com&lt;/a&gt;, and &lt;a href=&quot;https://paulwillard.nz&quot; target=&quot;_blank&quot;&gt;Paulwillard.nz&lt;/a&gt;), you can read about it here: &lt;a href=&quot;/linux/jekyll/bash/development/2018/10/17/Jekyll-Getting-Started.html&quot;&gt;Jekyll Getting Started&lt;/a&gt;.  &lt;br /&gt;
I want to talk about validation.&lt;/p&gt;

&lt;h2 id=&quot;not-all-web-browser-are-equal&quot;&gt;Not all web browser are equal&lt;/h2&gt;
&lt;p&gt;This is straight from the w3 website:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;While contemporary Web browsers do an increasingly good job of parsing even the worst HTML “tag soup”, some errors are not always caught gracefully. Very often, different software on different platforms will not handle errors in a similar fashion, making it extremely difficult to apply style or layout consistently.  &lt;br /&gt;
Using standard, interoperable markup and stylesheets, on the other hand, offers a much greater chance of having one’s page handled consistently across platforms and user-agents. Indeed, most developers creating rich Web applications know that reliable scripting needs the document to be parsed by User-Agents without any unexpected error, and will make sure that their markup and CSS is validated before creating a rich interactive layer.  &lt;br /&gt;
When surveyed, a large majority of Web professionals will state that validation errors is the first thing they will check whenever they run into a Web styling or scripting bug.  &lt;br /&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Basically, all browsers suck somehow. None of them do the right things, and they are always arguing about who is doing it right, and who is doing it wrong; boring !!&lt;/p&gt;

&lt;h2 id=&quot;what-i-do&quot;&gt;What I do&lt;/h2&gt;

&lt;p&gt;I try to write valid code ! It’s really simple.&lt;br /&gt;
Simple things like closing all your tags, creating valid headers, using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;amp;amp;&lt;/code&gt; instead of &amp;amp;.&lt;/p&gt;

&lt;h3 id=&quot;i-use-a-few-tools-to-check-my-work&quot;&gt;I use a few tools to check my work:&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;HTML Validator Chrome extension: &lt;a href=&quot;https://chrome.google.com/webstore/detail/html-validator/mpbelhhnfhfjnaehkcnnaknldmnocglk&quot; target=&quot;_blank&quot;&gt;Link here&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This little tool installs as part of the Chrome developer tools, and is a simple, quick test, of whether you’ve produced valid html.&lt;br /&gt;
This tool uses &lt;a href=&quot;http://www.html-tidy.org/&quot; target=&quot;_blank&quot;&gt;HTML-Tidy&lt;/a&gt; in the background. &lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://terminaladdict.com/assets/images/posts/thumbnails/HTML-Tidy.png&quot; alt=&quot;HTML-Tidy.png&quot; rel=&quot;lightbox&quot; class=&quot;shadow-lg rounded&quot; /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The w3c validator: &lt;a href=&quot;https://validator.w3.org/&quot; target=&quot;_blank&quot;&gt;Link here&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is a fantastic tool, but interestingly, returns different results to the previous mentioned tool; it must use a different validation tool, or whatever.&lt;br /&gt;
Absolutely use this during development, and before signing off as complete, on any web project. &lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The Structure Data testing tool: &lt;a href=&quot;https://search.google.com/structured-data/testing-tool/u/0/&quot; target=&quot;_blank&quot;&gt;Link here&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here’s a quote from Google:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Google Search works hard to understand the content of a page. You can help us by providing explicit clues about the meaning of a page to Google by including structured data on the page.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So Structured Data lets you define and describe your website data. I use this extensively at &lt;a href=&quot;https://www.loudas.com&quot; target=&quot;_blank&quot;&gt;Loudas.com&lt;/a&gt;, as the data is “bloggy”, and it’s used fairly heavily here too.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Chrome “Lighthouse test”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the Chrome developer tools there is a tab titled “Audits”. This uses a chrome tool called lighthouse.&lt;br /&gt;
This is awesome! Not only does it test validity of your website, but also suggested ways to make your website faster.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://terminaladdict.com/assets/images/posts/thumbnails/Lighthouse-tests.png&quot; alt=&quot;Lighthouse-tests.png&quot; rel=&quot;lightbox&quot; class=&quot;shadow-lg rounded&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Challenge yourself to see if you can get 100% across all tests. But here’s a warning, you’re going to learn about &lt;sup id=&quot;fnref:3&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;ServiceWorkers if you don’t already know about them.&lt;/p&gt;

&lt;h2 id=&quot;the-benefits&quot;&gt;The Benefits&lt;/h2&gt;

&lt;p&gt;Well this is also simple; things tend to work better when they’re using a standard.&lt;br /&gt;
You’ll likely come across less browser based bugs. But as I mentioned earlier, all browsers suck, so the key word here is &lt;em&gt;likely&lt;/em&gt; :)&lt;br /&gt;
Plus, you can gloat on forums about how awesome your website is, and how somebody elses is rubbish.&lt;/p&gt;

&lt;p&gt;Actually, don’t do that last one, instead just send them this link, and say something like “bro, want some help?”.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Do better work that meets standards :) there are heaps of tools to help you out along the way.&lt;/p&gt;

&lt;p&gt;Got some cool tools you use? Drop me a comment and let me know.&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;The HTML Validator extension has started causing an error in the console: Unchecked runtime.lastError: The message port closed before a response was received. &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Some of my “paid” work is terrible ! The customers don’t seem to value validation, and therefore won’t pay for my time to work through errors in their web apps (read: Wordpress installs). &lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;I use &lt;a href=&quot;https://github.com/GoogleChrome/workbox&quot; target=&quot;_blank&quot;&gt;Google Chrome - Workbox&lt;/a&gt; as my ServiceWorker, you can read through my source to see how I use it. &lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;</content><author><name>paul</name></author><category term="development" /><summary type="html">So I do a bit of web development, and of course have developed all 3 my own sites numerous times. I’m currently using Jekyll for my own sites (TerminalAddict.com, Loudas.com, and Paulwillard.nz), you can read about it here: Jekyll Getting Started. I want to talk about validation.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://terminaladdict.com/no-image.png" /><media:content medium="image" url="https://terminaladdict.com/no-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Comments On Blogs Vs Social Media</title><link href="https://terminaladdict.com/development/2018/11/06/Comments-on-blogs-vs-Social-Media.html" rel="alternate" type="text/html" title="Comments On Blogs Vs Social Media" /><published>2018-11-06T00:00:00+13:00</published><updated>2018-11-06T00:00:00+13:00</updated><id>https://terminaladdict.com/development/2018/11/06/Comments-on-blogs-vs-Social-Media</id><content type="html" xml:base="https://terminaladdict.com/development/2018/11/06/Comments-on-blogs-vs-Social-Media.html">&lt;p&gt;So I’ve run a blog for years, since 2006. Sometimes I blog about personal adventures, sometimes I share coding and sys admin things, sometimes I just talk rubbish. So this thing has been on my mind for a while &lt;strong&gt;Comments&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It’s so easy to comment on Facebook, Instagram, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;insert social media site here&amp;gt;&lt;/code&gt;.
Developers ( like me ) try &lt;em&gt;really&lt;/em&gt; &lt;em&gt;really&lt;/em&gt; hard to make it easy for people to comment on personal blogs too.&lt;/p&gt;

&lt;p&gt;Look here for an example, it’s simple, there is no sign up, no “confirm your email address”, simple! Just fill out a form and click submit.&lt;/p&gt;

&lt;p&gt;&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;There’s no magic in the background either. As of writing this (2018) there are no cookies used on this site, no data collection, no database in the background where I send info to advertisers, &lt;strong&gt;nothing&lt;/strong&gt;. and yet, it’s so difficult to get people to comment on our own websites?&lt;/p&gt;

&lt;p&gt;The media landscape kinda forces us, as website owners, to share our pages on facebook, twitter, instagram, whatever … and they (the social media websites) really have captured the “comments” market.&lt;/p&gt;

&lt;p&gt;For some reason people just don’t like commenting on a private website, but they have no problem commenting on social media sites?!?!?&lt;/p&gt;

&lt;h2 id=&quot;the-problem&quot;&gt;The problem&lt;/h2&gt;
&lt;p&gt;So, the problem from a website owners point of view is - success breeds success. and showing that you’re successful is important to give your website credibility. If people see that others have commented, then they are more comfortable commenting.&lt;/p&gt;

&lt;p&gt;But if that comment is on another social media site they don’t see it on the private website. :( &lt;em&gt;sad face&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Also there is a Google search problem.&lt;/p&gt;

&lt;p&gt;Google is by far the largest search engine in the world. Most people find my websites through Google. &lt;strong&gt;BUT&lt;/strong&gt; if your comment is on another social media site, Google doesn’t see it, that means Google thinks “Gee this site is inactive, I’ll stop recommending it to people”. :( &lt;em&gt;bigger sad face&lt;/em&gt;&lt;/p&gt;

&lt;h2 id=&quot;the-solution&quot;&gt;The solution&lt;/h2&gt;
&lt;p&gt;Well, I’m not sure. People need to trust a website, trust that it’s OK, that the website owner is not going to sell their details to some advertiser, or use their email address to spam.&lt;/p&gt;

&lt;p&gt;Then, the whole world needs to shift their ideas of how to interact with other people online.&lt;/p&gt;

&lt;p&gt;Facebook is dying, like actually .. fewer and fewer people use it. They’re sick of the advertising, the “share this if you agree” bollocks, the whole thing has just turned into a mess. Photo sharing like instagram has become popular (instagram is owned by facebook, so they’re probably selling your details like they always have) but it is no good for text blogging; Should we go back to the old fashioned days of visiting people. :)&lt;/p&gt;

&lt;h3 id=&quot;call-in-for-a-cuppa&quot;&gt;Call in for a cuppa&lt;/h3&gt;
&lt;p&gt;Back in the bad old days, you used to call in to see your friends, share a cup of coffee, catch up, then do it all again in two weeks.&lt;/p&gt;

&lt;p&gt;Do we go back to that idea? “I’ll just call into TerminalAddict.com and have a cuppa” :)&lt;br /&gt;
Sounds ridiculous, but maybe that’s just what’s needed ? Who knows?&lt;/p&gt;

&lt;p&gt;I’d love to hear your thoughts .. leave a comment :D&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;I do use google analytics to track visits to my website .. but that’s it. &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;</content><author><name>paul</name></author><category term="development" /><summary type="html">So I’ve run a blog for years, since 2006. Sometimes I blog about personal adventures, sometimes I share coding and sys admin things, sometimes I just talk rubbish. So this thing has been on my mind for a while Comments</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://terminaladdict.com/no-image.png" /><media:content medium="image" url="https://terminaladdict.com/no-image.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry></feed>