<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: David Rogers</title>
    <description>The latest articles on Forem by David Rogers (@h4ppyr0gu3).</description>
    <link>https://forem.com/h4ppyr0gu3</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F720301%2F7f7ad145-2274-4b9a-a04d-1a99c682aa15.jpeg</url>
      <title>Forem: David Rogers</title>
      <link>https://forem.com/h4ppyr0gu3</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/h4ppyr0gu3"/>
    <language>en</language>
    <item>
      <title>Intro to Unix Shell Commands</title>
      <dc:creator>David Rogers</dc:creator>
      <pubDate>Wed, 28 Sep 2022 12:45:37 +0000</pubDate>
      <link>https://forem.com/h4ppyr0gu3/intro-to-unix-shell-commands-50j1</link>
      <guid>https://forem.com/h4ppyr0gu3/intro-to-unix-shell-commands-50j1</guid>
      <description>&lt;h3&gt;
  
  
  TL;DR
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Essential file movement:
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;man&lt;/code&gt;, &lt;code&gt;ls&lt;/code&gt;, &lt;code&gt;pwd&lt;/code&gt;, &lt;code&gt;touch&lt;/code&gt;, &lt;code&gt;rm&lt;/code&gt;, &lt;code&gt;mkdir&lt;/code&gt;, &lt;code&gt;rmdir&lt;/code&gt;, &lt;code&gt;cd&lt;/code&gt;, &lt;code&gt;cp&lt;/code&gt;, &lt;code&gt;mv&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Essential Knowledge:
&lt;/h4&gt;

&lt;p&gt;flags change the behaviour of the command so read through the &lt;code&gt;man&lt;/code&gt; pages to find out what is possible and what the result will be&lt;br&gt;
the most important flag is &lt;code&gt;-h&lt;/code&gt; or &lt;code&gt;--help&lt;/code&gt;, these will print the help pages which are more concise than the man pages but at the same time more limited&lt;/p&gt;
&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;There are a few essential commands to learn to get started with a unix operating system&lt;br&gt;
These are default shell commands which should be a good foundation to begin to use the terminal more, obviously this is not an extensive list but should allow you to find further resources&lt;/p&gt;
&lt;h3&gt;
  
  
  flags
&lt;/h3&gt;

&lt;p&gt;flags are preceded by a dash and modify the functionality of the program so for example &lt;code&gt;ls -a&lt;/code&gt; is just &lt;code&gt;ls&lt;/code&gt; with the &lt;code&gt;-a&lt;/code&gt; flag&lt;/p&gt;
&lt;h3&gt;
  
  
  man
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;man&lt;/code&gt; are the linux man pages and takes a program name as an argument and gives detailed documentation of how exactly each available flag will modify the programs functionality&lt;br&gt;
for example:&lt;br&gt;
we can run the following command &lt;code&gt;man ls&lt;/code&gt; to list the flags available to the ls command, in here we will find a lot of modifiers that could make our lives easier such as the &lt;code&gt;-a&lt;/code&gt; flag which will print hidden directories as well as the standard ones, we could also use the &lt;code&gt;--color&lt;/code&gt; flag which will colorize the output allowing us to easily differentiate between directories and different file extensions&lt;/p&gt;

&lt;p&gt;
  &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TVucrANg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0hjm4xbz7h6v8cl48px9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TVucrANg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0hjm4xbz7h6v8cl48px9.png" width="880" height="1016"&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  ls
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;ls&lt;/code&gt; simply translates to list directory contents, there are multiple flags for ls which make it more capable, from the screenshot of the ls man page you can see that there is a lot that can be edited and a lot of flags available&lt;br&gt;
This command is very basic but forms the backbone of many peoples daily workflow to know where they are in the computer and whats around you&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vCyZdFYm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m6f6lu5xpmv24sbog731.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vCyZdFYm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m6f6lu5xpmv24sbog731.png" alt="ls command" width="880" height="500"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  pwd
&lt;/h3&gt;

&lt;p&gt;Now that we know what is around us, we need to know where we are to do that we can use&lt;code&gt;pwd&lt;/code&gt; if the shell prompt doesn't let you know your location already. &lt;code&gt;pwd&lt;/code&gt; takes no arguments and simply prints the current path and exits&lt;/p&gt;

&lt;p&gt;
  &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QtQoeYag--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9w6j481fsy6f0nsezqp9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QtQoeYag--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9w6j481fsy6f0nsezqp9.png" width="320" height="80"&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  touch
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;touch&lt;/code&gt; creates an empty file with the name as an argument and can also take a relative path&lt;br&gt;&lt;br&gt;
&lt;em&gt;N.B.&lt;/em&gt; an error will be thrown unless the directory exists that you are trying to create the file in&lt;/p&gt;
&lt;h3&gt;
  
  
  rm
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;rm&lt;/code&gt; removes a file by passing the file name or path as an argument, it can also remove a directory by passing the &lt;code&gt;-r&lt;/code&gt; flag before specifying the path or directory name but it is usually used to delete single files&lt;br&gt;&lt;br&gt;
&lt;em&gt;N.B.&lt;/em&gt; Be aware of the power of &lt;code&gt;rm -rf /&lt;/code&gt; as this will recursively delete every file on your computer although it may need super user priveleges &lt;code&gt;sudo&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;
  &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vve8jGq2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e7sh0hqz55cdcxgh9jm0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vve8jGq2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e7sh0hqz55cdcxgh9jm0.png" width="598" height="1448"&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  sudo
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;sudo&lt;/code&gt; can precede most commands on this list and gives you access to the system as the root user  temporarily, you may have to use root priveleges when installing packages from your distro package repository&lt;/p&gt;

&lt;p&gt;&lt;del&gt;no image here&lt;/del&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  mkdir
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;mkdir&lt;/code&gt; means make directory and it does exactly that so you can create a directory in the current file or you can pass a relative path to the command.&lt;/p&gt;

&lt;h3&gt;
  
  
  rmdir
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;rmdir&lt;/code&gt; is the opposite of mkdir and can only remove empty directories so to remove a directory and its contents we use &lt;code&gt;rm&lt;/code&gt; with the &lt;code&gt;-r&lt;/code&gt; flag, which stands for recursive&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BBhO-Nie--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3qvtllz43bjpeprzbcvz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BBhO-Nie--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3qvtllz43bjpeprzbcvz.png" alt="mkdir and rmdir commands" width="880" height="128"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  cd
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;cd&lt;/code&gt; means change directory and allows us to move around changing our current working directory. The most useful commands with &lt;code&gt;cd&lt;/code&gt; are &lt;code&gt;cd ..&lt;/code&gt; which moves to a higher directory otherwise you can &lt;code&gt;cd&lt;/code&gt; into a directory below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HAgj6_0C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m95wm0shkps51vahxdxy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HAgj6_0C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m95wm0shkps51vahxdxy.png" alt="cd command" width="880" height="303"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  cp
&lt;/h3&gt;

&lt;p&gt;This is the terminal version of copy and all you have to do is pass the source and destination file to the program, i.e. &lt;code&gt;cp &amp;lt;source&amp;gt; &amp;lt;destination&amp;gt;&lt;/code&gt;, this will copy the source file to the destination file&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NDRYJovG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wkz0t2ed601vlo0ynani.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NDRYJovG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wkz0t2ed601vlo0ynani.png" alt="cp command" width="880" height="281"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  mv
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;mv&lt;/code&gt; is similar to &lt;code&gt;cp&lt;/code&gt; but it moves the source file to the destination location, it could also be considered a renaming tool because renaming is equivalent to moving to a new name&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hHlpmZ7E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yfkjy1ze5zm59nt944sv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hHlpmZ7E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yfkjy1ze5zm59nt944sv.png" alt="mv command" width="880" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;These are some basic shell commands but with them you will be able to move around your terminal as well as start to build on top of them, the most important thing to remember is that there are &lt;code&gt;man&lt;/code&gt; pages available with extensive documentation as well as the help flag which will sumarize everything&lt;/p&gt;

&lt;p&gt;Thanks for reading and good luck in your future endeavours&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Custom Domain Names and Subdomains for Development</title>
      <dc:creator>David Rogers</dc:creator>
      <pubDate>Tue, 10 May 2022 21:21:34 +0000</pubDate>
      <link>https://forem.com/h4ppyr0gu3/custom-domain-names-and-subdomains-for-development-14i2</link>
      <guid>https://forem.com/h4ppyr0gu3/custom-domain-names-and-subdomains-for-development-14i2</guid>
      <description>&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;Developing a &lt;a href="https://rubyonrails.org/"&gt;Ruby on Rails&lt;/a&gt; application with subdomains is much more difficult than you would imagine.&lt;br&gt;
Although we could just install &lt;a href="https://github.com/puma/puma-dev"&gt;puma-dev&lt;/a&gt; following the installation guide, we wouldn't  understand why that works, or how, and so we close our minds to whats down that rabbit hole.&lt;/p&gt;
&lt;h2&gt;
  
  
  Down the Rabbit Hole
&lt;/h2&gt;

&lt;p&gt;To implement any solution it certainly helps to know what is going on behind the scenes and so what we have to understand is that there is a local DNS service on our machines that is searching in the cache for any site ip addresses which we are trying to look for in our browser. This is all well and good but it doesn't consider our local ports or in our case port 80 with a custom domain name so what we need is a &lt;strong&gt;configurable&lt;/strong&gt; local DNS service that we can use to map 127.0.0.1 which is localhost by default to a custom domain able to handle subdomains.&lt;br&gt;
To do this we use &lt;a href="https://dnsmasq.org/"&gt;dnsmasq&lt;/a&gt;, however dnsmasq on its own will just return whatever is running on port 80 so we need a way to map our server which in my case was running on port 3000 to port 80 so for that we use &lt;a href="https://docs.nginx.com/"&gt;NGINX&lt;/a&gt; as a proxy server/reverse proxy.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--roov--dE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o67tsxallvyehzly60os.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--roov--dE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o67tsxallvyehzly60os.png" alt="Image description" width="800" height="281"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  setting up NGINX
&lt;/h2&gt;

&lt;p&gt;installing NGINX on linux is pretty simple as it should be provided by default by the package manager of your distro, if not you may have to jump through some hoops to get it installed but for this blog that is outside the scope&lt;br&gt;
So... assuming nginx wasn't to difficult to install we shall continue.&lt;br&gt;
The next step is to configure nginx so that our application is served at &lt;code&gt;http://localhost/&lt;/code&gt; instead of &lt;code&gt;http://localhost:3000/&lt;/code&gt;, the difference being that by default a url withot the port specified, is directed to port 80 if it is using the HTTP protocol and port 443 if it is using the HTTPS protocol.&lt;br&gt;
To do that we to configure NGINX to pass/proxy our traffic from port 80 to port 3000.&lt;br&gt;
This is achived in the following configuration which will be somewhere in the /etc/nginx/ directory (location may vary):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http {
    .
    .
    .
    server {
        listen       80;
        server_name custom.domain *.custom.domain;

        location / {
            proxy_pass http://localhost:3000;
            proxy_redirect off;
            proxy_set_header Host $host;
        }
        .
        .
        .
    }
    .
    .
    .
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;N.B&lt;/strong&gt; there will be other configurations in the both the server and http blocks which don't need to be removed or changed&lt;/p&gt;

&lt;p&gt;The important code being &lt;code&gt;listen 80;&lt;/code&gt; and &lt;code&gt;proxy_pass http://localhost:3000&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;now if everything has gone according to plan we should see our website at &lt;code&gt;http://localhost/&lt;/code&gt; if we exclude the line with &lt;code&gt;server_name&lt;/code&gt; in our configuration.&lt;/p&gt;

&lt;p&gt;to add a custom domain name we need to add dnsmasq and the line including &lt;code&gt;server_name&lt;/code&gt; to our NGINX config so first install and configure dnsmasq.&lt;/p&gt;

&lt;h2&gt;
  
  
  dnsmasq
&lt;/h2&gt;

&lt;p&gt;Install dnsmasq from the default package manager or follow the recommended installation for your distro from the docs.&lt;br&gt;
dnsmasq generates a massive default config file with explanatory comments for every option however it is easier to just append to the file as you may want to change something else in future.&lt;br&gt;
For our purposes we are going to add the following to our config file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;port=53
domain-needed
bogus-priv
address=/custom.domain/127.0.0.1
address=/.custom.domain/127.0.0.1
listen-address=127.0.0.1
bind-interfaces
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;port=53&lt;/code&gt; runs dnsmasq as the default local DNS&lt;br&gt;
&lt;code&gt;domain-needed&lt;/code&gt; and &lt;code&gt;bogus-priv&lt;/code&gt; prevent packets with malformed domain names and packets with private IP addresses from leaving your network, don't ask me what this means because I am not entirely sure, more info can be found &lt;a href="https://www.linux.com/topic/networking/advanced-dnsmasq-tips-and-tricks/"&gt;here&lt;/a&gt;.&lt;br&gt;
the &lt;code&gt;address&lt;/code&gt; lines add custom.domain to the server redirecting them to 127.0.0.1 which is where our service is running as mentioned earlier on port 80 which is default lookup&lt;br&gt;
the .custom.domain allows for subdomains to also be resolved&lt;br&gt;
&lt;code&gt;listen-address&lt;/code&gt; is self explanatory and is then listening on localhost&lt;br&gt;
&lt;code&gt;bind-interfaces&lt;/code&gt; binds all interfaces and updates if some interfaces get dropped or changed.&lt;/p&gt;
&lt;h2&gt;
  
  
  Setting dnsmasq as default
&lt;/h2&gt;

&lt;p&gt;by default on systemd systems the default DNS resolver is systemd-resolved so to enable dnsmasq which listens on the same port we have to first disable systemd-resolved by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl stop systemd-resolved
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl disable systemd-resolved
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This should destroy some symlinked files so that the service won't run on start up.&lt;br&gt;
we then need to enable dnsmasq by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl &lt;span class="nb"&gt;enable &lt;/span&gt;dnsmasq
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl start dnsmasq
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All this has done at this stage is enable dnsmasq as the default DNS server and allowed it to redirect custom.domain to port 80 which should allow us to use subdomains and use the custom address but if we would like to add multiple custom domains we need to restrict the proxy server to only proxy custom.domain, to do that we add the following line to our nginx config under the listen command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;server_name custom.domain *.custom.domain;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Adding 127.0.0.1 to /etc/resolv.conf
&lt;/h2&gt;

&lt;p&gt;Because we are using dnsmasq as our default DNS server we need it to resolve both local requests and internet wide and so it is using the /etc/resolv.conf file to look up the DNS server of the router or internet connection we are using, so to add ourselves to the list of available nameservers we have to append &lt;code&gt;nameserver 127.0.0.1&lt;/code&gt; to our &lt;code&gt;/etc/resolv.conf&lt;/code&gt; file, by doing this we have allowed our DNS server to first consider our local entries. &lt;br&gt;
I have this set up in an alias in my .zshrc file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;alias &lt;/span&gt;nameserver:add&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"sudo sed -i '1s/^/# Custom Entry&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;nameserver 127.0.0.1&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;/' /etc/resolv.conf"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Putting it all together
&lt;/h2&gt;

&lt;p&gt;Everything is in place and near ready to go so to get it all running together we may need to restart our services and visit the page:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl restart nginx
&lt;span class="nb"&gt;sudo sed&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="s1"&gt;'1s/^/# Custom Entry\nnameserver 127.0.0.1\n/'&lt;/span&gt; /etc/resolv.conf
&lt;span class="c"&gt;# the above command can be replaced by nameserver:add if you have sourced your shell file&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl restart dnsmasq
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Adding more domains
&lt;/h2&gt;

&lt;p&gt;To add an additional domain add an address to the dnsmasq config file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;address=/new.domain/127.0.0.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And add a server to the NGINX config file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http {
    .
    .
    .
    server {
        listen       80;
        server_name custom.domain *.custom.domain;

        location / {
            proxy_pass http://localhost:3000;
            proxy_redirect off;
            proxy_set_header Host $host;
        }
        .
        .
        .
    }

    server {
        listen       80;
        server_name new.domain;

        location / {
            proxy_pass http://localhost:4000;
            proxy_redirect off;
            proxy_set_header Host $host;
        }
        .
        .
        .
    }
    .
    .
    .
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;If you have any problems the official docs are the ultimate source of truth&lt;br&gt;
This solution may not work for everyone but it works very well for me&lt;/p&gt;
&lt;h3&gt;
  
  
  Update
&lt;/h3&gt;

&lt;p&gt;I have since moved away from using /etc/resolv.conf and have updated dnsmasq.conf to use a custom resolver file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# /etc/dnsmasq.conf

port=53
domain-needed
bogus-priv
address=/custom.domain/127.0.0.1
address=/.custom.domain/127.0.0.1
listen-address=127.0.0.1
bind-interfaces
resolv-file=/etc/dnsmasq-resolv.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# /etc/dnsmasq-resolv.conf

# localhost
nameserver 127.0.0.1
# Google DNS
nameserver 8.8.8.8
nameserver 8.8.4.4
# Cloudflare DNS
nameserver 1.1.1.1
nameserver 1.0.0.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;by doing this i don't need to alias auto writing to resolv.conf, and hopefully these DNS servers are fast enough, but in case they are not, the last line of dnsmasq.conf can be undone and you can use your local resolv.conf file&lt;/p&gt;

&lt;p&gt;You also have to turn off the NetworkManager DNS service by editing /etc/NetworkManager/NetworkManager.conf&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# /etc/NetworkManager/NetworkManager.conf

[main]
dns=none
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I updated to this latest version because my dns service was slow and impacted my work, i hope someone else can benefit from this&lt;/p&gt;

</description>
      <category>rails</category>
      <category>linux</category>
      <category>ruby</category>
      <category>webdev</category>
    </item>
    <item>
      <title>The Journey to Arch</title>
      <dc:creator>David Rogers</dc:creator>
      <pubDate>Fri, 15 Apr 2022 23:53:42 +0000</pubDate>
      <link>https://forem.com/h4ppyr0gu3/the-journey-to-arch-5d7o</link>
      <guid>https://forem.com/h4ppyr0gu3/the-journey-to-arch-5d7o</guid>
      <description>&lt;p&gt;As all Arch users began with Ubuntu I guess it is only fair that that is where I started as well. I started watching reviews on GNOME versions and soon came to realize the limitations of a stable distro: You don't get access to the cutting edge packages and features and so I simply had to change to Arch.&lt;/p&gt;

&lt;p&gt;Nope it wasn't that simple, in fact I first changed to the 6 month release from Ubuntu which was not an LTS version in order to try out a few of the latest GNOME improvements, I then tried to install docker which is unsupported on any version of ubuntu that is not LTS which makes sense. So I thought to go to the root of the cause.&lt;/p&gt;

&lt;p&gt;Debian Bullseye Is the father of all these Ubuntu releases so it must have access to the latest packages right? Well not unless you change the apt repository to the unstable version where you can't not have a package, They must have everything there?&lt;br&gt;
Dependency errors, that's it. You are left with a system of half stable and half unstable, trying to install some of the latest software compiling from github because there is no alternative repository hosting all this custom software except on github.&lt;/p&gt;

&lt;p&gt;I had been flirting with the idea of moving to Arch as well, looking in the mirror and telling myself I am a hardcore Linux user. So.... I have the bright idea of dual booting Arch and Debian. I had installed Arch on a virtual machine so I thought I was ready but a slight lack of judgement and understanding on my part whilst installing Debian was that I chose to go with Logical Volume Management which I still don't know what it does so my Debian installation was in a boot loop after seeing that the size of the LVM and available size on the partitition were different.&lt;br&gt;
Well S**t.&lt;/p&gt;

&lt;p&gt;As much as I told myself I was a hardcore Linux user it seemed an opportune time to live up to it so Arch it is - although it wasn't really a choice, it was now the only bootable ISO image I had on hand. I installed Arch 3 times that day, GRUB couldn't figure out where and to be honest neither could I.&lt;/p&gt;

&lt;p&gt;After successfully installing Arch I went about getting back all my settings which at this stage were no longer dependent on GNOME because as a hardcore Linux user it has to be a window manager, and so after pulling all my dotfiles and configuring everything again, finding some packages was such a breeze after learning the dirty secrets of the Arch User Repository and so rarely had to compile untested github code&lt;/p&gt;

&lt;p&gt;For some of us looking for the bleeding edge we all start with a user friendly distro but after changing so many times to try and get the latest and greatest software I guess the only constant is change and as Arch is always changing I hope that that will keep me away from distro hopping.  &lt;/p&gt;

</description>
      <category>archlinux</category>
      <category>ubuntu</category>
      <category>debian</category>
    </item>
  </channel>
</rss>
