Fixing timeout between Nginx and PHP-FPM

SysadminIn case you've set up Nginx as reverse proxy for PHP-FPM and you have very slow or complex PHP script that executes for quite some time, you've probably seen an 504 gateway time-out error. This is pretty common error, but in most cases people are barking at the wrong tree and they're having difficulties finding out which timeout directive is the right one for their scenario.

I've seen some people desperately experimenting with proxy_read_timeout, send_timeout, even client_header_timeout and client_body_timeout directives, but if they bothered to take a peek into Nginx's error_log, they would've seen an error such as:


Exim ACL for blocking certain senders

This is definitely not spamIf you're in a need for fast and simple solution to block certain senders directly on Exim mail server, you're in luck. Couple of weeks back I needed to blacklist a spammer on a relay mail server, so that I could take my time and carefully trace the origin server/script from where the spam was being sent.

Implementing sender blocklist is very simple. Just open Exim's configuration file - if you're using CentOS or RHEL, look no further than /etc/exim/exim.conf. On Debian based distributions Exim's configuration is split into multiple files, so the recommended way of reconfiguring Exim is with dpkg-reconfigure exim4-config.


AWStats - poor man's download counter

Condescending WonkaA few days ago I was asked to configure AWStats to count downloads of .exe files on an website. I know that it's blindingly obvious that AWStats isn't the right tool for this job, but sometimes you have to pick battles with your clients. To save both my time and sanity I did what I was asked to do.

Interestingly, adding file download tracking functionality to AWStats proved to be very easy. In my case, the website was hosted on a cPanel server where AWStats was already installed, so I won't cover the whole installation procedure.


Change passwords for multiple cPanel accounts (bulk password reset)

Geeks and repetitive tasksThe other day I needed to change passwords for multiple cPanel accounts. Since there was a lot accounts in question, changing passwords manually was out of the question. Changing passwords from shell using passwd utility was also out of the question because that would change only the password for Unix user - MySQL and FTP passwords would remain unchanged. In the end I wrote a simple script which automates changing system, FTP and MySQL passwords for cPanel user.


Adding custom modules to Nginx RPM

Skeptical babyIf you've installed Nginx from source, adding custom modules is easy. You simply recompile Nginx and include the module you want. But what if you've installed Nginx from RPM? How do you install custom module in this case? Well, you'll need to repackage RPM and although it may sound really complicated, it's not that big of a deal.

In this example, I'll explain how to include Frickle's Nginx slow cache module for caching static files. This module is excellent if your static files are stored on a slow filesystem (e.g. NFS storage, slow HDD's). To speed things up, Nginx can fetch these files once, and then cache them on a faster filesystem (e.g. local SAS/SSD). This way, Nginx will serve the files much faster and you'll minimize the network traffic.