Author: Daniel

  • [Ubuntu] curl: (6) Could not resolve host

    By changing a domain’s DNS I ended up with curl: (6) Could not resolve host issue. I lost a couple of hours before I resolved. The post is all about how resolved the issue.

    I recently installed Vanilla forum on TapThatBrain.com. I wanted Vanilla to send out emails when I register users from Vanilla’s dashboard.

    The cloud web hosting that I use doesn’t come with a mail server out the box. So I thought of using a SMTP relay service. Using a SMTP relay service demanded changing the domain’s DNS eventually leading me to the issue — curl: (6) Could not resolve host issue.

    I took the following approach before I finally resolved the issue.

    1. At first, I thought I messed up my nginx configurations. But my configuration was set up to listen both locations — tapthatbrain.com and www.tapthatbrain.com. So my nginx config was good. Did you know? You can use command line to verify if nginx configurations are in place before reloading the nginx server. Learn how.
    2. I noticed that when I go to tapthatbrin.com, I was redirected to www.tapthatbrain.com and I wanted to find out where the redirection comes from — nginx, certbot or WordPress. Did you know? You can use curl -I tapthatbrain.com to identify the HTTP response using the command line.
    3. The redirection was clearly not from my nginx configuration.
    4. WordPress may possibly cause the redirection. The values of WP_HOME and WP_SITEURL in WordPress were www.tapthatbrain.com. But I wasn’t sure if WordPress caused the redirection. So I used WP CLI to update the value to tapthatbrain.com. But the redirection continued to happen.
    5. Finally, Certbot’s configuration in nginx made the redirection. In that case I know I should be able to access the website using www.tapthatbrain.com. But I was not able to access using the www version.
    6. So, my next thought was the router’s DNS cache. Since I use Jio Fiber connection, I followed the steps listed at https://www.reliancedigital.in/solutionbox/how-to-change-your-dns-to-browse-faster-and-safer/ to clear the DNS cache at router level. But clearing the DNS cache at router level didn’t help.
    7. I thought of accessing the both versions (www and the non-www) of the website using a different internet connection. Fortunately, I was able to access both versions using my mobile data.
    8. That meant something went wrong at Ubuntu (or system) level. Ubuntu couldn’t resolve the DNS. A quick search on Stack Overflow reveled a solution that worked.

    Once I updated the /etc/resolve.conf file, I was able to access both versions of the website tapthatbrain.com from my Ubuntu machine.

    This issue could seem naive for someone with decent Ubuntu skills. However, I don’t feel I’m put to shame for sharing this instance. Instead, I see this as learning opportunity.

    Today, I’m grateful to all my mentors for all their motivation. They made me stronger each day.

  • Vanilla — Pretty Permalinks

    Being a long time user of WordPress, I love the pretty permalink feature. This feature in WordPress works out of the box.

    I started using Vanilla recently on a website that I run and manage and found that the forum application is not using pretty permalinks.

    I could have used nginx server blocks to rewrite the URLs using the rewrite directive but before that I wanted to find out if Vanilla ships with this feature, out of the box.

    Turns out that Vanilla’s pretty permalink feature can be enabled using the config like shown in https://stackoverflow.com/a/53923139/5569979

    Set the following config in /conf/config-defaults.php

    $Configuration['Garden']['RewriteUrls'] = true;

    That’s all you need to do. If pretty permalinks don’t work for you then make sure to get the nginx configuration right. Read Vanilla — A BBPress Alternative to learn more about nginx configuration for Vanilla.

  • Vanilla — A BBPress Alternative

    I needed a searchable knowledge base, a forum, to use on Tap That Brain website. At first, BBPress looked like a great option. But it turned out to be ineffective with the block based theme I use called Quadrat.

    Stack Overflow for Teams was next on my list. However, I didn’t like the fact that my users have to leave my website to find information. So I had to explore further.

    I ran into thread, titled “Looking for alternatives“, on BBPress forum. Crazy, isn’t it? However, that thread made me realize how a forum can foster community interactions.

    I found Ipstenu’s comment in the thread. Ipstenu is a well known name in the WordPress space. So I was more inclined to explore her list of alternatives. Out of the many options, I chose to go with Vanilla. I like the fact that Vanilla is a open source software.

    Things to consider

    1. TapThatBrain.com is powered by WordPress. I have installed WordPress application on the root directory. For the sake of understanding, let us assume that the root directory is /var/www/tapthatbrain.com/
    2. I would like to have a forum at TapThatBrain.com/forum

    Installation

    Download the Vanilla application from https://open.vanillaforums.com/download. From their documentation, installation appeared to be simple. But it wasn’t the case with me.

    Unzip the downloaded file at /var/www/tapthatbrain.com/forum and navigate to TapThatBrain.com/forum on the browser to complete the installation.

    Setting up the nginx server block was quite challenging. Vanilla’s documentation has listed the config to be included with nginx. However, I had to tweak it a bit to get it working with my setup.

    NGINX configuration

    Here’s how I got Vanilla working alongside WordPress. In my case, I know all forum requests are routed through TapThatBrain.com/forum/

    NGINX cannot process PHP files. We use FastCGI to handle PHP processing. I shall talk more about this in a minute. But let us see how I handle all /forum/ requests before that.

    Handling the /forum/ requests.

    location /forum/ {
      try_files $uri $uri/ index.php$is_args$args;
    }

    The above statement matches all requests made to /forum/ and executes the file. If the file isn’t available, it executes the folder. If the folder isn’t available then it executes index.php and passes any $args received.

    The above block worked great at first. However, I needed to handle requests like /forum/categories/, /forum/discussions/, etc.

    location /forum/ {
      try_files $uri $uri/ @vanilla;
    }
    
    location @vanilla {
      rewrite ^/forum/(.*)$ /forum/index.php?p=$1 last;
    }

    The goal of the above block is to rewrite the URLs like /forum/categories/ and /forum/discussions/ and rewrite them as TapThatBrain.com/forum/index.php?p=discussions and you get the idea.

    We want the rewrite to happen because these URLs are dynamic and are not actual pages. You can read more about the last keyword mentioned in the rewrite directive.

    FastCGI PHP processing

    In order to process PHP files, we use FastCGI. Pass the fastcgi_pass value and the processing should kick in.

    location /forum/ {
      location /forum/index\.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_param SCRIPT_NAME /forum/index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root/index.php;
        fastcgi_param X_REWRITE 1;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
      }
    
      try_files $uri $uri/ @vanilla;
    }
    
    location @vanilla {
      rewrite ^/forum/(.*)$ /forum/index.php?p=$1 last;
    }

    A nested location block is added for the FastCGI processing. The nested location block looks for the /forum/index.php. Now I have to re-route all requests via index.php file.

    I would soon update this post about re-routing requests via index.php

    With this current setup, I will be able to let Tap That Brain users access a forum without leaving the website.

    If you’re curious, checkout the forum at https://www.tapthatbrain.com/forum/

  • Goodbye Droplet. Hello 👋 Nanode!

    I made the decision to self-host my WordPress blog four years ago. I was reluctant at first. But being a developer, I wanted to expand my server administration skills.

    Digital Ocean was popular in the cloud web hosting territory back then and their documentation and affordability were icing on the cake. I spun up a server with my limited knowledge and things were pretty good.

    Four years later, here I’m sharing my experience with Digital Ocean. In these four years, my servers crashed twice. Because of the way I had set up my files, I lost all my data. I wouldn’t blame Digital Ocean for the loss of data.

    However, I got pretty uncomfortable the second time I lost the data. The urge to move to a different cloud web hosting was stronger than ever. So I started looking for alternatives.

    I remembered using Linode at work a couple of years ago. I never experienced an issue with their reliability. Without second thought, I opted for Linode.

    Making the switch

    I chose to go with Linode’s starter plan — Nanode. Because I know I can expand later. Moving to Linode also meant revisiting my server administration skills. But this time, I had a couple of things in mind —

    1. Setup backs to prevent losing database and files
    2. Tighten up server security

    Setting up a server this time wasn’t as complex as I did four years ago. I matured enough to be able to know a bit more of the server-side stuff. Not only did I set up the server (Nanode) but also attached a block storage to my Nanode for data backups.

    I documented everything that I did while setting up using Obsidian, a cross-platform note taking app. A couple of weeks passed by since I made the switch. The backups make me feel safe allowing me to sleep peacefully.

    Today, I’m grateful for the Almighty for the life I live.

  • Handling My Male Dog Around A Female Stray In Heat

    Every few months one or the other female in my neighborhood goes in to heat. The scent of the female in heat intrigues my male Labrador and managing him becomes very challenging.

    I have bred my male dog with suitable females a couple of times. However, his urge to reproduce is only on the rise.

    Whining, squealing and pacing are common, out of barrier frustration, in male dogs when they sense a female in heat. Here is what I do to manage my male dog during those times.

    1. Stay more vigilant and turn around long before my dog sees a female in heat during our walks.
    2. Play more games at home with my dog to keep him occupied. Tugging, chasing toys and brain games are our favourites.
    3. I don’t pester my dog when he shows little to no interest in food. Reduced food consumption is common during these times.
    4. Use therapeutic aroma oils like Lavender oil or Tea tree oil to calm my dog. An electric diffuser would be handy and easy to use.
    5. Restrict access to outdoor view points in the house like windows, doors, L-shaped stairs. I restrict because my dog would constantly bark if allowed otherwise.
    6. Last, but not the least, we have to remember that our dogs will learn to cope as they mature. Yes, patience is our friend.

    Do you face challenges managing your male dog? How do deal with ’em? Let me know in the comments. I would love to read your strategies 🙂

  • My Software Development Tool Kit

    Recently I switched to using ThinkPad E15 laptop and had to install all the applications I use on a daily basis. Ubuntu is my go to operating system.

    To cut back time thinking to come up with the list of all applications I need, I thought of listing ’em down in a blog post. I’m falling in love in Ubuntu everyday I use it.

    Cerebral debugger

    Download Cerebral debugger (snap package) and install using the snap command.

    sudo snap install /path/to/my-snap.snap --dangerous

    Composer

    Download and install Composer globally.

    php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
    php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
    php composer-setup.php
    php -r "unlink('composer-setup.php');"
    sudo mv composer.phar /usr/local/bin/composer

    cURL

    To download Oh My Zsh, cURL is required. Install cURL using the following command.

    sudo apt install curl

    Git

    Download and install Git using the following command.

    sudo apt install git

    KSnip

    Install KSnip using Snap.

    sudo snap install ksnip

    Local

    Download and Install Lhttps://localwp.com/ocal.

    sudo apt install ./local-6.x.x-linux.deb

    Obsidian

    Download and Install Obsidian.

    sudo snap install --dangerous obsidian_0.x.x_amd64.snap

    Peek

    Install Peek.

    sudo apt install peek

    Slack

    Install Slack using Snap.

    sudo snap install slack --classic

    VS Code

    Install VS Code using Snap.

    sudo snap install code --classic

    Zoom Client

    Install VS Code using Snap.

    sudo snap install zoom-client

    Zsh

    Install Zsh.

    sudo apt install zsh

    Oh My Zsh

    Oh My Zsh is downloaded using cURL. Since cURL is already installed, we could download Oh My Zsh.

    sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  • Hello world!

    Hello world!

    Yay! I got my blog up and running.

    I, recently, crashed my Digital Ocean droplet by running a reboot command in the terminal losing all my blog’s data.

    I’ve been using Digital Ocean for fours years. The recent crash is the second bad experience with Digital Ocean and I decided to switch to using Nanode.

    I learnt the lesson the hard way — save database backups in a different server other than the actual web server.

    The unfortunate event forced me to brush up my server administration skills, which I wouldn’t have done otherwise. You see, inconvenience is sometimes good.

    I intend to share what I learn in this blog. By sharing, I only help my future self. If you benefit from this blog in any way, I would be glad to know. Do share your words in the comments.

    Susan Garrett, a renowned dog trainer, inspired me to end blog posts with a gratitude note.

    So, here I go — I’m grateful for my mentors who made me what I’m today.

    Image Credit

    1. Photo by Vladislav Klapin on Unsplash