Traffic Advice configuration for Nginx

If you have been seeing 404s for /.well-known/traffic-advice in your access logs from the Chrome Privacy Preserving Prefetch Proxy bot, you’re not alone. It’s Google Chrome’s private prefetch proxy intended to decrease the Largest Contentful Paint (LCP) performance metric for faster perceived page loads. There are a few guides (including the first answer on the Stack Overflow question I linked earlier) to have your web server respond correctly to these requests.

Deploy to Cloudflare Pages with Gitlab CI

Cloudflare Pages is an amazing service to host your SSG and static HTML websites on edge locations and serve pages with low latency around the world. However the product is still new and isn’t as full-featured as I’d want it to be. One of the deficiencies is the lack of deployment options - only GitHub and GitLab.com hosted repositories are supported seamlessly - for anything else, we need to use Wrangler or directly upload a folder or a Zip file through the Cloudflare dashboard GUI.

Hugo Subscript and Superscript Shortcodes

In its current avatar, there’s no way to get superscript or subscript text in your Hugo content without directly embedding <sup> or <sub> tags in your posts and setting unsafe: true in the Goldmark renderer settings in config.yaml. A cleaner alternative is to use shortcodes to embed these tags in the content. This keeps us from having to enable HTML tags in all posts, and we can have our Markdown content files looking mostly clean.

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: '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 PATHINFOpermalinks, 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/nginx.pid –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]