Monday, 21 October 2013

Remove X-Powered-By header in Nginx server

It is often desired to remove the 'X-Powered-By' from the HTTP headers. When using Nginx, it can be using a simple setting. The setting has to be in http section and it takes the following form.

<module_name>_hide_header X-Powered-By;

For example, if it is a FastCGI server the configuration setting will be as follows:

fastcgi_hide_header X-Powered-By;

If you are using Nginx as a load balancer, the configuration setting will be as follows:

proxy_hide_header X-Powered-By;

Unfortunately this configuration setting is not available yet in Passenger because Passenger is a thord party module and they have not implemented it yet.

Saturday, 19 October 2013

SVN export using capistrano

If you are using SVN for version control and
capistrano for deployments, capistrano does code checkout from the application machines. It is often preferable to use svn export instead of svn checkout. Capistrano defaults to checkout, but it can be configured to use export by setting the :deploy_via parameter to 'export' in deployment script.

Friday, 11 October 2013

Retrieving crontab after accidental removal

Yesterday at my workplace someone accidentally deleted all entries in crontab. We started looking for ways of restoring it as fast as possible. The tedious way of finding all processes on that machine would be our last option and it would also miss out frequency optimization done on the machine for various crons set on it.

Based on the usual Unix practice of backing up every file while saving an edit, we wanted to find out if the same happens with crontab too. To do that we needed to find out where crontab file was stored. A look at the manual page using the following command was enough to tell us that the file was stored at /var/spool/cron/.

man 8 cron

Looking in the folder, we could see the empty crontab file but no backup file was found. At this point, we did not have much hope of retrieving. Just to try our luck we tried looking at /tmp folder and fortune did favour us. We found the following file which had the previous contrab entries.