Follow your debian server updates by email with apticron

apticron is a shell script that send you an email report when new packages are available on your debian server.

Install apticron

As root, do:

apt-get install apticron

apticron configuration via /etc/apticron/apticron.conf

To receive reports on your email change the EMAIL variable in the configuration file. By default, reports are sent to the root user.

EMAIL="root" -> EMAIL="you@domain.com"

Reports received

Now apticron will send you reports like this:

apticron report [Sat, 26 Jul 2008 06:45:47 +0200]
==============================================
apticron has detected that some packages need upgrading on:

        localhost.localdomain

        [ 127.0.0.1 XXX.XXX.XXX.XXX ]

The following packages are currently pending an upgrade:

        lighttpd 1.4.13-4etch10

========================================================================

Package Details:

Reading changelogs...

--- Changes for lighttpd ---

lighttpd (1.4.13-4etch10) stable-security; urgency=low

  [ Pierre Habouzit ]

  * Non-maintainer upload.

  * Fix [CVE-2008-1531] patches mess, and add a missing hunk of the patch.

 -- Thijs Kinkhorst thijs debian org  Tue, 22 Jul 2008 12:19:10 +0200

========================================================================

You can perform the upgrade by issuing the command:

        aptitude dist-upgrade

as root on localhost.localdomain

It is recommended that you simulate the upgrade first to confirm that the actions that
would be taken are reasonable. The upgrade may be simulated by issuing the command:

        aptitude -s -y dist-upgrade

--
apticron

Apticron files

For more informations, you can have a look to those files:

/etc/cron.daily/apticron
/usr/sbin/apticron

This entry was written by CharlyBr, posted on July 30, 2008 at 7:34 am, filed under Distro and tagged , , . Leave a comment or view the discussion at the permalink.

Maintenance mode (HTTP 503) with lighttpd and PHP

When you put your website in maintenance mode, it’s a good idea to return a HTTP 503 error code to the client.

This code indicates that “the server is currently unable to handle the request due to a temporary overloading or maintenance of the server”.

The 503 code is used to avoid crawlers or caching proxy use the maintenance page as the new valid content for the request. You certainly don’t want Google save this content in his search index as the content of your website :)

To achieve this we will use a rewrite rule in lighttpd to redirect all requests to a single PHP script which will return a 503 error code and print an informative message.

Lighttpd configuration

url.rewrite = ( "" => "/maintenance.php" )

This configuration will redirect any request to maintenance.php script.

If you need to serve an image in your maintenance page, you have to add another rule to the rewrite process like that :

url.rewrite = ( "upgrading.png" => "$0",
                "" => "/maintenance.php" )

Let some users see the website

It might be usefull to let admins or developers access the website during the maintenance.
For that, you can disable the maintenance rewrite rule for certain IP addresses :

 $HTTP["remoteip"] != “192.168.1.42″ {
               url.rewrite = ( "upgrading.png" => "$0",
                      "" => "/maintenance.php" )
}

PHP code example

<?php
header("HTTP/1.1 503 Service Unavailable");
?>
We're currently upgrading our servers...

Links

This entry was written by CharlyBr, posted on July 22, 2008 at 2:28 am, filed under http and tagged , . Leave a comment or view the discussion at the permalink.

Rotate Nginx log files under FreeBSD

To rotate your nginx log files, you can use the log file handler provided by FreeBSD: newsyslog.

Configuring /etc/newsyslog.conf

/var/log/nginx-access.log               644  7     1024 *     JC /var/run/nginx.pid
/var/log/nginx-error.log                644  7     1024 *     JC /var/run/nginx.pid

Before log rotation:

-rw-r--r--  1 root  wheel    104278002 Jul 16 11:35 nginx-access.log
-rw-r--r--  1 root  wheel      1509531 Jul 16 11:17 nginx-error.log

After log rotation:

-rw-r--r--  1 root  wheel        967 Jul 16 12:42 nginx-access.log
-rw-r--r--  1 root  wheel    5310443 Jul 16 12:41 nginx-access.log.0.bz2
-rw-r--r--  1 root  wheel         77 Jul 16 12:41 nginx-error.log
-rw-r--r--  1 root  wheel      37552 Jul 16 12:41 nginx-error.log.0.bz2

Links

This entry was written by CharlyBr, posted on July 17, 2008 at 7:15 am, filed under Logs and tagged , , . Leave a comment or view the discussion at the permalink.