Add a Canonical URL tag to your Hugo site

While working with a barebone Hugo theme, I noticed that it doesn’t have a canonical URL meta tag. I have a publicly accessible development site because of the inticracies of my deployment procedure, and it is quite important that it is not picked up and indexed by search engines. Canonical URLs become really important in this context. Well, thankfully it was really easy to add. I needed to override the template file that defined the <head> section of our pages.

Monitoring a process for high memory consumption using Monit

I run Pi-hole on an old PogoPlug E02 with a custom compiled dnsmasq (or pihole-FTL, as they now call their customised version of it). Lately I have been noticing my DNS queries becoming slow erratically, and upon further investigation it looked like pihole-FTL has a memory balloon, and it consumes all of the 256 MBs of memory available and starts swapping, bringing everything to an almost standstill. In comes Monit, a highly configurable process supervisor.

Using parted’s resizepart non-interactively on a busy partition

I had a situation where I needed to spin up a virtual machine from a template, and if the new virtual machine’s disk was larger, I needed to resize the partition and then ‘grow’ the filesystem. Well, as with any thing, that you need to do for more than once, I tried to script it using Ansible and incorporate it into our existing VM provisioning scripts. First step was to figure out command we need to run.

Saving state information between GitLab CI runs

I had a unique scenario where I had to find out if certain files (in a specific directory) changed in between GitLab CI job runs. One of my original ideas was to run jobs on changes to certain files using only:changes (link). This had two problems – first of all, this would run on every commit regardless of which files were changed/added (even with only:changes, the job would be initiated, but would not run any tasks), and that’s a waste of resources.

Resolving “‘unknown’: unknown terminal type.” error

Last day, after updating the repositories and installing the updated packages on my Debian Lenny, I found that I could no longer run top or use nano or vi to open a file. It threw up this nasty error: #top<br /> 'unknown': unknown terminal type. After a bit of sleuthing, I came to the conclusion that my default console terminal type was defined as ‘unknown’, which, obviously, isn’t correct. To display your default terminal type, use this :

WordPress permalinks in nginx

WordPress generally works out-of-the box on nginx. The posts load fine, the functions in the dashboard work pretty well, until you come to the permalinks. If you are on Apache, with mod_rewrite, WordPress will automatically add the required rewrite rules to your .htaccess file for permalinks to work. But for nginx, you have to add the rules manually. Moreover, when WordPress detects that mod_rewrite is not loaded (which is the case with nginx), it falls back to using PATHINFO permalinks, which inserts an extra ‘index.

IPv6 support in nginx

To enable IPv6 support in nginx, we need to check whether it has been compiled with --with-ipv6 flag. To check, fire up the terminal and type in this command : [code language=”bash”]nginx -V[/code] The results should be something like this : [code language=”bash”]nginx version: nginx/0.7.65 TLS SNI support enabled configure arguments: –conf-path=/etc/nginx/nginx.conf –error-log-path=/var/log/nginx/error.log –pid-path=/var/run/ –lock-path=/var/lock/nginx.lock –http-log-path=/var/log/nginx/access.log –http-client-body-temp-path=/var/lib/nginx/body –http-proxy-temp-path=/var/lib/nginx/proxy –http-fastcgi-temp-path=/var/lib/nginx/fastcgi –with-debug –with-http_stub_status_module –with-http_flv_module –with-http_ssl_module –with-http_dav_module –with-http_gzip_static_module –with-http_realip_module –with-mail –with-mail_ssl_module –with-ipv6 –add-module=/build/buildd/nginx-0.7.65/modules/nginx-upstream-fair[/code]

Nginx reduces page load time, increases Googlebot activity

After a small incident with a shared host, I moved my phpBB forum and a few other static sites to a VPS running on nginx. Nginx is a small, lightweight but very efficient web server created by Igor Sysoev, originally developed for, Russia’s second-largest web site. Due to it’s light-weightedness and efficiency, it is used by a lot of high traffic sites like WordPress, Hulu, Github, Ohloh, SourceForge, TorrentReactor, etc.

Enable directory listing in nginx

Enabling directory listing in a folder in nginx seems simple enough with just an autoindex on; directive inside the location directive. However, for some reason, it didn’t work for me. I finally got it to work by moving the root directive out of location. So, if you have something like this : [code]server { listen 80; server_name; access_log /var/………………………; location / { root /path/to/root; index index.php index.html index.htm;

Www/no-www rewrite rules for nginx

There are many ways to rewrite www urls to their non-www versions in nginx. Here one that’s Igor-approved and works well on my setup : WWW to Non-WWW: [code]#301 redirect www to non-www server { listen [::]:80; server_name; rewrite ^$request_uri? permanent; } server { listen [::]:80; server_name; ………………………………….. ………………………………….. }[/code] Non-WWW to WWW: [code]#301 redirect non-www to www server { listen [::]:80; server_name; rewrite ^ http://www.