<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" ><channel><title>Kevin Deldycke &#187; Web</title> <atom:link href="http://kevin.deldycke.com/tag/web/feed/" rel="self" type="application/rss+xml" /><link>http://kevin.deldycke.com</link> <description>Free software engineer &#38; wannabe videomaker</description> <lastBuildDate>Fri, 03 Feb 2012 19:08:27 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>Live Browser : a Python web app using Microsoft Live Connect API</title><link>http://kevin.deldycke.com/2011/12/live-browser-python-web-app-microsoft-live-connect-api/</link> <comments>http://kevin.deldycke.com/2011/12/live-browser-python-web-app-microsoft-live-connect-api/#comments</comments> <pubDate>Tue, 06 Dec 2011 11:27:03 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[English]]></category> <category><![CDATA[API]]></category> <category><![CDATA[Boilerplate]]></category> <category><![CDATA[bootstrap]]></category> <category><![CDATA[cherrypy]]></category> <category><![CDATA[cloud-computing]]></category> <category><![CDATA[Git]]></category> <category><![CDATA[GitHub]]></category> <category><![CDATA[javascript]]></category> <category><![CDATA[jquery]]></category> <category><![CDATA[mako]]></category> <category><![CDATA[microsoft]]></category> <category><![CDATA[microsoft live connect]]></category> <category><![CDATA[mongodb]]></category> <category><![CDATA[OAuth]]></category> <category><![CDATA[Python]]></category> <category><![CDATA[Web]]></category><guid isPermaLink="false">http://kevin.deldycke.com/?p=3901</guid> <description><![CDATA[5 months ago I was called by a recruiter for a position in a startup building cloud-computing solutions. At the end of my first interview with the engineers of the company, I was asked to write a little web application &#8230; <a href="http://kevin.deldycke.com/2011/12/live-browser-python-web-app-microsoft-live-connect-api/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>5 months ago I was called by a recruiter for a position in a startup building cloud-computing solutions. At the end of my first interview with the engineers of the company, I was asked to write a little web application to test my technical abilities.</p><p>The goal was to create a back-end talking to <a href="http://msdn.microsoft.com/windowslive">Microsoft&#8217;s Live Connect API</a> and keep a cache of user profiles. Then a front-end demonstrating my HTML/CSS/JS know-how was to be built. User authentication was supposed to use <a href="http://oauth.net">OAuth</a>.</p><p>The only technological constraint was to use Python. I decided to use <a href="http://cherrypy.org">CherryPy</a> and <a href="http://www.makotemplates.org">Mako</a> to leverage the <a href="http://kevin.deldycke.com/2011/08/cherrypy-mako-formish-ooop-boilerplate/">boilerplate code I just released back then</a>. For the persistent layer, my first intention was to use <a href="http://www.sqlalchemy.org">SQLAlchemy</a>, but quickly switched to <a href="http://www.mongodb.org">MongoDB</a> as I never played with it and this project was a great opportunity to.</p><p>If my web app was far from finished, it was still well-received by the team. After other interviews I was made an competitive offer. I finally declined as I wanted to finish what I stated at my current company.</p><p>What&#8217;s left of this experience is <em>Live Browser</em>, the web app I created, which <a href="https://github.com/kdeldycke/live_browser">source code is now available on GitHub</a>.</p> ]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2011/12/live-browser-python-web-app-microsoft-live-connect-api/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Installation Guide for a full-featured Debian server</title><link>http://kevin.deldycke.com/2011/10/installation-guide-full-featured-debian-server/</link> <comments>http://kevin.deldycke.com/2011/10/installation-guide-full-featured-debian-server/#comments</comments> <pubDate>Tue, 18 Oct 2011 10:32:20 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[English]]></category> <category><![CDATA[apt]]></category> <category><![CDATA[cron]]></category> <category><![CDATA[Debian]]></category> <category><![CDATA[Exim]]></category> <category><![CDATA[fail2ban]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[maintenance]]></category> <category><![CDATA[munin]]></category> <category><![CDATA[MySQL]]></category> <category><![CDATA[nginx]]></category> <category><![CDATA[nut]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Server]]></category> <category><![CDATA[SMART]]></category> <category><![CDATA[squeeze]]></category> <category><![CDATA[system]]></category> <category><![CDATA[Web]]></category><guid isPermaLink="false">http://kevin.deldycke.com/?p=3165</guid> <description><![CDATA[Here is a collection of articles I wrote during the past year. Together they form a guide that will let you setup a full-featured Debian server. All of these tutorials are based on the recent work I did to setup &#8230; <a href="http://kevin.deldycke.com/2011/10/installation-guide-full-featured-debian-server/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Here is a collection of articles I wrote during the past year. Together they form a guide that will let you setup a full-featured Debian server. All of these tutorials are based on the recent work I did to setup my personal server on Debian Squeeze.</p><p>These articles are independent with each other, meaning you can pick the one your interested in to customize your server and ignore the others.</p><ol><li>Setup <a href="http://kevin.deldycke.com/2011/05/setting-hdds-smart-monitoring-debian-squeeze/">SMART</a> monitoring tool for HDDs.</li><li>Setup <a href="http://kevin.deldycke.com/2011/05/mge-ellipse-750-ups-debian-squeeze/">Nut</a> to manage the UPS.</li><li>Setup <a href="http://kevin.deldycke.com/2011/09/cloud-based-server-backups-duplicity-amazon-s3/">Duplicity and Amazon S3</a> for cloud-based backups.</li><li>Setup <a href="http://kevin.deldycke.com/2011/05/how-to-gmail-send-mails-debian-squeeze/">Exim</a> to relay mails via Gmail.</li><li>Setup <a href="http://kevin.deldycke.com/2011/05/fresh-debian-thanks-to-cron-apt/">cron-apt</a> to keep our distribution up to date.</li><li>Add a <a href="http://kevin.deldycke.com/2011/06/configuring-fail2ban-debian-squeeze/">fail2ban</a> deamon.</li><li>Setup <a href="http://kevin.deldycke.com/2011/06/munin-monitor-debian-squeeze-server/">Munin</a> to monitor our machine.</li><li><a href="http://kevin.deldycke.com/2011/06/nginx-php-fpm-mysql-debian-squeeze-server/">Basic setup of Nginx + PHP-FPM + MySQL</a> web stack.</li><li><a href="http://kevin.deldycke.com/2011/09/nginx-php-fpm-mysql-configuration/">Optimizing Nginx + PHP-FPM + MySQL</a> for performances.</li><li>Setup <a href="http://kevin.deldycke.com/2011/07/php-apc-debian-squeeze-munin-monitoring/">PHP APC</a> op-code cache.</li><li>Install <a href="http://kevin.deldycke.com/2011/08/entropy-debian-squeeze-server/">haveged</a> to get lots of entropy.</li><li>Setup a <a href="http://kevin.deldycke.com/2011/07/lighttpd-powered-webdavs-server-debian-squeeze/">WebDAVs</a> server with Lighttpd.</li><li>Setup <a href="http://kevin.deldycke.com/2011/09/setup-mailman-nginx-exim-debian-squeeze/">Mailman + Nginx + Exim</a> for mailing-lists.</li><li>Mailman <a href="http://kevin.deldycke.com/2011/10/mailman-migration/">mailing-list migration</a> and <a href="http://kevin.deldycke.com/2011/10/how-to-merge-mailman-mailing-lists/">merging</a>.</li></ol> ]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2011/10/installation-guide-full-featured-debian-server/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>My Nginx + PHP-FPM + MySQL configuration</title><link>http://kevin.deldycke.com/2011/09/nginx-php-fpm-mysql-configuration/</link> <comments>http://kevin.deldycke.com/2011/09/nginx-php-fpm-mysql-configuration/#comments</comments> <pubDate>Tue, 20 Sep 2011 10:22:13 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[English]]></category> <category><![CDATA[Debian]]></category> <category><![CDATA[debian squeeze]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[MySQL]]></category> <category><![CDATA[nginx]]></category> <category><![CDATA[ovh]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[php-fpm]]></category> <category><![CDATA[Server]]></category> <category><![CDATA[virtual server]]></category> <category><![CDATA[virtualization]]></category> <category><![CDATA[Web]]></category> <category><![CDATA[WordPress]]></category><guid isPermaLink="false">http://kevin.deldycke.com/?p=3594</guid> <description><![CDATA[This article is a follow-up to the one I wrote 3 months ago, in which I explained how to install a web stack based on Nginx, PHP-FPM and MySQL on a Debian Squeeze server. Now it&#8217;s time to tune this &#8230; <a href="http://kevin.deldycke.com/2011/09/nginx-php-fpm-mysql-configuration/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>This article is a follow-up to the one I wrote 3 months ago, in which I explained how to <a href="http://kevin.deldycke.com/2011/06/nginx-php-fpm-mysql-debian-squeeze-server/">install a web stack based on Nginx, PHP-FPM and MySQL</a> on a Debian Squeeze server. Now it&#8217;s time to tune this basic install to get some performance out of it.</p><p><a href="http://kevin.deldycke.com/wp-content/uploads/2011/08/ovh-vps-3-virtual-server.png"><img src="http://kevin.deldycke.com/wp-content/uploads/2011/08/ovh-vps-3-virtual-server-150x150.png" alt="" title="ovh-vps-3-virtual-server" width="150" height="150" class="alignleft size-thumbnail wp-image-3801" /></a> The setup I&#8217;ll detail below runs on an <a href="http://www.ovh.co.uk/vps/">OVH VPS</a> instance. This virtual server has 4 CPU cores at 1.5GHz, 1 Go RAM and 50 Gb HDD.</p><p>I&#8217;m mostly running WordPress instances on that server, so you&#8217;ll see some reference of it in this post.</p><h2>MySQL</h2><p>First, let&#8217;s tune MySQL. That&#8217;s the easiest part of that article, as you only need to create a <code>.cnf</code> file in <code>/etc/mysql/conf.d/</code> and place there all your custom parameters. Here is the content of my <code>/etc/mysql/conf.d/kev.cnf</code>:</p><pre class="brush: plain; title: ; notranslate">
[mysqld]
interactive_timeout = 50
join_buffer = 1M
key_buffer = 250M
max_connections = 100
max_heap_table_size = 32M
myisam_sort_buffer_size = 96M
query_cache_limit = 4M
query_cache_size = 250M
query_prealloc_size = 65K
query_alloc_block_size = 128K
read_buffer_size = 1M
read_rnd_buffer_size = 768K
sort_buffer_size = 1M
table_cache = 4096
thread_cache_size = 1024
tmp_table_size = 32M
wait_timeout = 500
# Debug
#general_log_file = /var/log/mysql/mysql.log
#general_log = 1
# InnoDBinnodb_buffer_pool_size = 256Minnodb_additional_mem_pool_size = 10Minnodb_log_file_size = 32Minnodb_flush_method = O_DIRECTinnodb_file_per_table = 1innodb_flush_log_at_trx_commit = 0
[mysqld_safe]
nice = -5
open_files_limit = 8192

[isamchk]
key_buffer = 64M
sort_buffer = 64M
read_buffer = 16M
write_buffer = 16M
</pre><p>Most of these parameters were set for my particular usage and with insights from the <a href="http://launchpad.net/mysql-tuning-primer">MySQL Tuning Primer Script</a>.</p><h2>PHP-FPM</h2><p>Unlike MySQL, the structure of PHP configuration files on Debian Squeeze doesn&#8217;t let us easily add our customizations. We have to modify the default files provided at the package installation.</p><p>Here is my setup of the PHP processes pool:</p><pre class="brush: diff; title: ; notranslate">
--- /etc/php5/fpm/pool.d/www.conf.orig     2011-06-07 08:14:30.000000000 +0200
+++ /etc/php5/fpm/pool.d/www.conf  2011-08-15 17:34:09.000000000 +0200
@@ -237,3 +237,10 @@
 ;php_admin_value[error_log] = /var/log/fpm-php.www.log
 ;php_admin_flag[log_errors] = on
 ;php_admin_value[memory_limit] = 32M
+
+pm.max_children = 25
+pm.start_servers = 4
+pm.min_spare_servers = 2
+pm.max_spare_servers = 10
+pm.max_requests = 500
+request_terminate_timeout = 30
</pre><p>The second customization I made is not about performances but convenience. It just allow my WordPress&#8217; users to upload larger files:</p><pre class="brush: diff; title: ; notranslate">
--- /etc/php5/fpm/php.ini.orig      2011-06-18 13:32:37.000000000 +0200
+++ /etc/php5/fpm/php.ini   2011-06-22 22:50:49.000000000 +0200
@@ -725,7 +725,7 @@

 ; Maximum size of POST data that PHP will accept.
 ; http://php.net/post-max-size
-post_max_size = 8M
+post_max_size = 15M

 ; Magic quotes are a preprocessing feature of PHP where PHP will attempt to
 ; escape any character sequences in GET, POST, COOKIE and ENV data which might
@@ -876,7 +876,7 @@

 ; Maximum allowed size for uploaded files.
 ; http://php.net/upload-max-filesize
-upload_max_filesize = 2M
+upload_max_filesize = 15M

 ; Maximum number of files that can be uploaded via a single request
 max_file_uploads = 20
</pre><h2>Nginx</h2><p>Let&#8217;s say my WordPress blog is installed in <code>/var/www/my_wordpress</code>. To let it be served by Nginx, we add a configuration file for this site in <code>/etc/nginx/sites-available/my_wordpress</code>:</p><pre class="brush: plain; title: ; notranslate">
server {
  server_name blog.example.com;
  root /var/www/my_wordpress/;
  include /etc/nginx/wordpress.conf;
  location /static {
    autoindex on;
  }
}

server {
  listen 80 default_server;
  server_name .example.com .example.org .example.net;
  rewrite ^ http://blog.example.com$request_uri? permanent;
}
</pre><p>In the configuration above, you can see that I want my blog to be served at <code>http://blog.example.com</code>. I also added some domain redirections in the form of a second <code>server</code> section, and a way to better display my static file repository by letting Nginx generate index pages.</p><p>Then don&#8217;t forget to activate this site:</p><pre class="brush: bash; title: ; notranslate">
$ ln -s /etc/nginx/sites-available/my_wordpress /etc/nginx/sites-enabled/
</pre><p>The file above refer to <code>/etc/nginx/wordpress.conf</code> which is where I place all the configuration directives common to all the WordPress blogs on my server. Here is the content of that file:</p><pre class="brush: plain; title: ; notranslate">
# This order might seem weird - this is attempted to match last if rules below fail.
# See: http://wiki.nginx.org/HttpCoreModule
location / {
  try_files $uri $uri/ /index.php?q=$uri&amp;$args;
}

# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;

include global.conf;

include php.conf;
</pre><p>Again, this file make a reference to <code>php.conf</code>, which is the same as <a href="http://kevin.deldycke.com/2011/06/nginx-php-fpm-mysql-debian-squeeze-server/">the one featured in my previous article</a>. I only removed the <code>index</code> directive to place it elsewhere, and added a limit on the number of PHP requests a client can make:</p><pre class="brush: plain; title: ; notranslate">
location ~ \.php$ {
  # Throttle requests to prevent abuse
  limit_req zone=antidos burst=5;

  # Zero-day exploit defense.
  # http://forum.nginx.org/read.php?2,88845,page=3
  # Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi.
  # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine.  And then cross your fingers that you won't get hacked.
  try_files $uri =404;

  fastcgi_split_path_info ^(.+\.php)(/.+)$;
  include /etc/nginx/fastcgi_params;

  # As explained in http://kbeezie.com/view/php-self-path-nginx/ some fastcgi_param are missing from fastcgi_params.
  # Keep these parameters for compatibility with old PHP scripts using them.
  fastcgi_param PATH_INFO       $fastcgi_path_info;
  fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

  # Some default config
  fastcgi_connect_timeout        60;
  fastcgi_send_timeout          180;
  fastcgi_read_timeout          180;
  fastcgi_buffer_size          128k;
  fastcgi_buffers            4 256k;
  fastcgi_busy_buffers_size    256k;
  fastcgi_temp_file_write_size 256k;

  fastcgi_intercept_errors    on;
  fastcgi_ignore_client_abort off;

  fastcgi_pass 127.0.0.1:9000;
}
</pre><p>Here is where the <code>index</code> directive moved: <code>/etc/nginx/conf.d/kev.conf</code>. I also added there some tweaks and the global request throttling configuration:</p><pre class="brush: plain; title: ; notranslate">
# Hide Nginx version
server_tokens off;

# Set default index file names
index index.php index.html index.htm;

# Allow uploads up to 15 Mo
client_max_body_size 15m;

# Create a global request accounting pool to prevent DOS
limit_req_zone $binary_remote_addr zone=antidos:10m rate=3r/s;
</pre><p>The <code>global.conf</code> file we saw in <code>/etc/nginx/wordpress.conf</code> refer to <code>/etc/nginx/global.conf</code>, which contain additional measures to remove cruft from log files and enhance security:</p><pre class="brush: plain; title: ; notranslate">
# Do not log excessive request on common web content like favicon and robots.txt
location = /favicon.ico {
  log_not_found off;
  access_log off;
}
location = /robots.txt {
  allow all;
  log_not_found off;
  access_log off;
}

# Deny all attempts to access any dotfile (=hidden files) such as .htaccess, .htpasswd, .DS_Store, .directory, .svn, .git, ...
location ~ /\. {
  deny all;
  access_log off;
  log_not_found off;
}
</pre><p>All of default Nginx configuration can&#8217;t be overridden by additional files. We have to change <code>/etc/nginx/nginx.conf</code> itself:</p><pre class="brush: diff; title: ; notranslate">
--- /etc/nginx/nginx.conf.orig   2011-06-06 00:46:56.000000000 +0200
+++ /etc/nginx/nginx.conf        2011-08-15 17:44:58.000000000 +0200
@@ -3,8 +3,9 @@
 pid /var/run/nginx.pid;

 events {
-       worker_connections 768;
-       # multi_accept on;
+       use epoll;
+       worker_connections 1024;
+       multi_accept on;
 }

 http {
@@ -16,7 +17,7 @@
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
-       keepalive_timeout 65;
+       keepalive_timeout 3;
        types_hash_max_size 2048;
        # server_tokens off;
</pre><p>That&#8217;s all for our customizations. We can now restart all our servers:</p><pre class="brush: bash; title: ; notranslate">
$ /etc/init.d/mysql restart
$ /etc/init.d/php5-fpm restart
$ /etc/init.d/nginx restart
</pre><h2>Conclusion</h2><p>I&#8217;m running my websties under this configuration for about 3 months and I&#8217;m really happy with the results. I&#8217;m sure I can push optimizations further, but it may require lots of time and effort compared to the marginal gain I&#8217;ll get. My websites are responsive enough to me. And if they collapse in the future under the load of the Reddit crowd, I&#8217;ll still have the option to move to a bigger virtual server (vertical scaling FTW!).</p> ]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2011/09/nginx-php-fpm-mysql-configuration/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>How-to fix Flash on Kubuntu</title><link>http://kevin.deldycke.com/2011/09/how-to-fix-flash-kubuntu/</link> <comments>http://kevin.deldycke.com/2011/09/how-to-fix-flash-kubuntu/#comments</comments> <pubDate>Tue, 06 Sep 2011 10:32:09 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[English]]></category> <category><![CDATA[adobe]]></category> <category><![CDATA[apt-get]]></category> <category><![CDATA[flash]]></category> <category><![CDATA[KDE]]></category> <category><![CDATA[kpackagekit]]></category> <category><![CDATA[kubuntu]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[package]]></category> <category><![CDATA[plugin]]></category> <category><![CDATA[Web]]></category><guid isPermaLink="false">http://kevin.deldycke.com/?p=3890</guid> <description><![CDATA[If like me you want the greatest and latest Flash version on your Kubuntu, you probably added the SevenMachine&#8217;s repository to your sources. Else, you should, as it&#8217;s where you&#8217;ll find all the fresh Flash packages, for both 32 bits &#8230; <a href="http://kevin.deldycke.com/2011/09/how-to-fix-flash-kubuntu/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>If like me you want the greatest and latest Flash version on your Kubuntu, you probably added the <a href="http://launchpad.net/~sevenmachines/+archive/flash">SevenMachine&#8217;s repository</a> to your sources. Else, you should, as it&#8217;s where you&#8217;ll find all the fresh Flash packages, for both 32 bits and 64 bits architectures.</p><p>Everything will be great after that. Until the day this repository is updated, which will break the Flash plugin if you attempt an upgrade with KPackageKit.</p><p><a href="http://kevin.deldycke.com/wp-content/uploads/2011/09/kpackagekit-flash.png"><img src="http://kevin.deldycke.com/wp-content/uploads/2011/09/kpackagekit-flash-300x174.png" alt="" title="kpackagekit-flash" width="300" height="174" class="aligncenter size-medium wp-image-3891" /></a></p><p>The Flash package does not contain the binary plugin itself, but is just an empty shell which download the plugin from the web to your machine. And for this operation to work as expected, the package need to be in a terminal environment.</p><p>To fix this, you&#8217;ll have to remove all previous Flash package (as a prevention measure), then install the latest with the command line. Here are the commands to do exactly this:</p><pre class="brush: bash; title: ; notranslate">
sudo apt-get remove --purge flashplugin-installer flashplugin64-installer
sudo apt-get clean
sudo apt-get update
sudo apt-get install flashplugin64-installer
</pre><p>Commands above are for a 64 bits distribution. If you&#8217;re still running a 32 bits Linux, just replace the last reference of <code>flashplugin64-installer</code> by <code>flashplugin-installer</code>.</p><p>Now restart your browser and YouTube videos and other Flash stuff should work again.</p> ]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2011/09/how-to-fix-flash-kubuntu/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>WebPing Open-sourced !</title><link>http://kevin.deldycke.com/2011/08/webping-open-sourced/</link> <comments>http://kevin.deldycke.com/2011/08/webping-open-sourced/#comments</comments> <pubDate>Tue, 16 Aug 2011 10:10:06 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[English]]></category> <category><![CDATA[Apache]]></category> <category><![CDATA[email]]></category> <category><![CDATA[flot]]></category> <category><![CDATA[GitHub]]></category> <category><![CDATA[HTML]]></category> <category><![CDATA[HTTP]]></category> <category><![CDATA[javascript]]></category> <category><![CDATA[jquery]]></category> <category><![CDATA[munin]]></category> <category><![CDATA[nagios]]></category> <category><![CDATA[plone]]></category> <category><![CDATA[Python]]></category> <category><![CDATA[Server]]></category> <category><![CDATA[sqlite]]></category> <category><![CDATA[Web]]></category> <category><![CDATA[webping]]></category> <category><![CDATA[yaml]]></category><guid isPermaLink="false">http://kevin.deldycke.com/?p=3715</guid> <description><![CDATA[I&#8217;ve just released WebPing under a GPL license. It&#8217;s available right now on a GitHub repository. WebPing is a script I started to work on in 2009 while working at EDF. Back then, I needed a monitoring tool to keep &#8230; <a href="http://kevin.deldycke.com/2011/08/webping-open-sourced/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>I&#8217;ve just released WebPing under a GPL license. It&#8217;s available right now on a <a href="http://github.com/kdeldycke/webping">GitHub repository</a>.</p><p>WebPing is a script I started to work on in 2009 while working at <a href="http://www.edf.com/">EDF</a>. Back then, I needed a monitoring tool to keep an eye on the 80+ <a href="http://plone.org/">Plone</a> instances that my team managed. For several corporate reasons, I wasn&#8217;t allowed to use a proper monitoring tool like <a href="http://munin-monitoring.org/">Munin</a> or <a href="http://www.nagios.org/">Nagios</a>. So I created a small script to fill this need. That&#8217;s how WebPing came to be.</p><p>WebPing is just a stupid Python script that is designed to be ticked regularly by a cron job. It try to fetch a list of URLs and store response times in an SQLite database. Then it create a static HTML report you&#8217;re free to serve with any HTTP server (an <a href="http://github.com/kdeldycke/webping/blob/master/apache.conf">example Apache configuration</a> is provided). The configuration of WebPing and the list of URLs it monitor is stored in a YAML file.</p><p>The produced HTML report use the <a href="http://code.google.com/p/flot">Flot jQuery plugin</a> to render graphs. Here is how the dashboard looks like:<br /> <a href="http://kevin.deldycke.com/wp-content/uploads/2011/08/webping-dashboard.png"><img src="http://kevin.deldycke.com/wp-content/uploads/2011/08/webping-dashboard-271x300.png" alt="" title="webping-dashboard" width="271" height="300" class="aligncenter size-medium wp-image-3777" /></a></p><p>Finally, WebPing is able to send reports and alerts by emails. Here is how a mail alert looks like:<br /> <a href="http://kevin.deldycke.com/wp-content/uploads/2011/08/webping-email-alert.png"><img src="http://kevin.deldycke.com/wp-content/uploads/2011/08/webping-email-alert-300x293.png" alt="" title="webping-email-alert" width="300" height="293" class="aligncenter size-medium wp-image-3743" /></a></p><p>Since I created WebPing, I found several other projects more or less developed around the same idea. See <a href="http://github.com/ericholscher/django-kong">Kong</a>, which is based on Django and <a href="http://twill.idyll.org/">Twill</a>, a web-oriented <a href="http://en.wikipedia.org/wiki/Domain-specific_language">DSL</a>. Another project I spotted after the facts was <a href="http://code.google.com/p/multi-mechanize">multi-mechanize</a>. Like Kong, it&#8217;s written in Python. But I never played with one or the other.</p> ]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2011/08/webping-open-sourced/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Lighttpd-powered WebDAVs server on Debian Squeeze</title><link>http://kevin.deldycke.com/2011/07/lighttpd-powered-webdavs-server-debian-squeeze/</link> <comments>http://kevin.deldycke.com/2011/07/lighttpd-powered-webdavs-server-debian-squeeze/#comments</comments> <pubDate>Tue, 26 Jul 2011 10:51:45 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[English]]></category> <category><![CDATA[Debian]]></category> <category><![CDATA[etch]]></category> <category><![CDATA[lighttpd]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[openssl]]></category> <category><![CDATA[Server]]></category> <category><![CDATA[ssl]]></category> <category><![CDATA[Web]]></category> <category><![CDATA[webdav]]></category><guid isPermaLink="false">http://kevin.deldycke.com/?p=357</guid> <description><![CDATA[Here is a tiny article about how I used Lighttpd to serve content over WebDAV. First, install the required packages: As we want to provide a secure WebDAV access, we need to install OpenSSL: Then we create the file /etc/lighttpd/clear-creds.lst, &#8230; <a href="http://kevin.deldycke.com/2011/07/lighttpd-powered-webdavs-server-debian-squeeze/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Here is a tiny article about how I used <a href="http://www.lighttpd.net">Lighttpd</a> to serve content over <a href="http://wikipedia.org/wiki/WebDAV">WebDAV</a>.</p><p>First, install the required packages:</p><pre class="brush: bash; title: ; notranslate">
$ aptitude install lighttpd-mod-webdav
</pre><p>As we want to provide a secure WebDAV access, we need to install <a href="http://www.openssl.org">OpenSSL</a>:</p><pre class="brush: bash; title: ; notranslate">
$ aptitude install openssl
</pre><p>Then we create the file <code>/etc/lighttpd/clear-creds.lst</code>, that will contain credentials required for authentication, under the following form:</p><pre class="brush: plain; title: ; notranslate">
user1:password1
user2:password2
user3:password3
</pre><p>Logins and passwords are stored here in clear. This is stupid, but for this project I was looking to setup a quick and dirty server. For temporary tests this setup is OK, but I encourage you to switch to a better credential storage system.</p><p>Now I want to serve WebDAV content within a secure channel. A self-signed SSL certificate will be enough. Let&#8217;s generate one:</p><pre class="brush: bash; title: ; notranslate">
$ cd /etc/lighttpd/
$ openssl req -x509 -nodes -subj '/' -days 3650 -newkey rsa:2048 -keyout server.pem -out server.pem
</pre><p>We&#8217;ll configure Lighttpd by loading the default parameters of modules we use:</p><pre class="brush: bash; title: ; notranslate">
$ cd /etc/lighttpd/conf-enabled/
$ ln -s ../conf-available/05-auth.log
$ ln -s ../conf-available/10-ssl.conf
$ ln -s ../conf-available/10-webdav.conf
</pre><p>Now I create a custom configuration file:</p><pre class="brush: bash; title: ; notranslate">
$ touch /etc/lighttpd/conf-available/99-custom.conf
$ cd /etc/lighttpd/conf-enabled/
$ ln -s ../conf-available/99-custom.conf
</pre><p>Here is the content of that <code>99-custom.conf</code> configuration file:</p><pre class="brush: plain; title: ; notranslate">
# Hide server version
server.tag = &quot;lighttpd&quot;

# Force all request to be in HTTPs
# This also redirects all WebDAV requests to WebDAVs
$HTTP[&quot;scheme&quot;] == &quot;http&quot; {
  $HTTP[&quot;host&quot;] =~ &quot;(.*)&quot; {
    url.redirect = ( &quot;^/(.*)&quot; =&gt; &quot;https://%1/$1&quot; )
  }
}

# Valid credentials are required for any request
auth.backend = &quot;plain&quot;
auth.backend.plain.userfile = &quot;/etc/lighttpd/clear-creds.lst&quot;
auth.require = (
  &quot;/&quot; =&gt; (
    &quot;method&quot; =&gt; &quot;digest&quot;,
    &quot;realm&quot; =&gt; &quot;My WebDAV server&quot;,
    &quot;require&quot; =&gt; &quot;valid-user&quot;
  )
)

# Enable WebDAV in read and write mode
webdav.activate = &quot;enable&quot;
webdav.is-readonly = &quot;disable&quot;

# Customize directory listings a bit
dir-listing.set-footer = &quot;&lt;a href='http://example.com'&gt;Company&lt;/a&gt;'s document repository.&quot;
</pre><p>And do not forget to restart the server:</p><pre class="brush: bash; title: ; notranslate">
$ /etc/init.d/lighttpd restart
</pre><p><a href="http://kevin.deldycke.com/wp-content/uploads/2011/07/lighttpd-webdav-server.png"><img src="http://kevin.deldycke.com/wp-content/uploads/2011/07/lighttpd-webdav-server-300x232.png" alt="" title="lighttpd-webdav-server" width="300" height="232" class="aligncenter size-medium wp-image-3441" /></a></p><p>As you can see in the screenshot above, you can now:</p><ul><li>Browse the file system in read/write mode with a WebDAV client via a <code>webdavs://12.34.56.78/</code> URL;</li><li>Access content in read-only mode with a browser by a classic <code>https://12.34.56.78/</code> URL.</li></ul> ]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2011/07/lighttpd-powered-webdavs-server-debian-squeeze/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>PHP APC on Debian Squeeze with Munin monitoring</title><link>http://kevin.deldycke.com/2011/07/php-apc-debian-squeeze-munin-monitoring/</link> <comments>http://kevin.deldycke.com/2011/07/php-apc-debian-squeeze-munin-monitoring/#comments</comments> <pubDate>Tue, 19 Jul 2011 10:28:10 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[English]]></category> <category><![CDATA[apx]]></category> <category><![CDATA[Debian]]></category> <category><![CDATA[debian squeeze]]></category> <category><![CDATA[munin]]></category> <category><![CDATA[nginx]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Server]]></category> <category><![CDATA[Web]]></category><guid isPermaLink="false">http://kevin.deldycke.com/?p=3269</guid> <description><![CDATA[Installing APC on Debian Squeeze is as simple as installing the package: In my case this package come from the PHP bundle distributed by the Dotdeb repository. If installing APC is easy, monitoring it with Munin requires some extra manipulations. &#8230; <a href="http://kevin.deldycke.com/2011/07/php-apc-debian-squeeze-munin-monitoring/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Installing <a href="http://php.net/manual/en/book.apc.php">APC</a> on Debian Squeeze is as simple as installing the package:</p><pre class="brush: bash; title: ; notranslate">
$ aptitude install php5-apc
</pre><p>In my case this package come from the PHP bundle distributed by the <a href="http://www.dotdeb.org">Dotdeb repository</a>.</p><p>If installing APC is easy, monitoring it with Munin requires some extra manipulations. There is currently no good <a href="http://exchange.munin-monitoring.org/plugins/search?keyword=apc">APC plugin available on Munin Exhange</a>. So we&#8217;ll use the external <a href="http://code.google.com/p/munin-php-apc/">munin-php-apc project</a> instead.</p><p>The latter can&#8217;t get APC statistics by itself: it need an extra PHP file to be served locally. As you can read in my previous article, <a href="http://kevin.deldycke.com/2011/06/munin-monitor-debian-squeeze-server/">my Munin is powered by Nginx</a>. So now we&#8217;ll setup Nginx to serve this extra PHP file:</p><pre class="brush: bash; title: ; notranslate">
$ mkdir -p /var/www/apc
$ cd /var/www/apc
$ wget http://munin-php-apc.googlecode.com/svn/trunk/php_apc/apc_info.php
$ chown -R www-data:www-data /var/www/apc
</pre><p>Then I need to update my <code>/etc/nginx/sites-available/munin</code> file (see <a href="http://kevin.deldycke.com/2011/06/munin-monitor-debian-squeeze-server/">details about this file on my previous article</a>) to have the second <code>server</code> section look like this:</p><pre class="brush: plain; title: ; notranslate">
server {
  server_name localhost;
  include /etc/nginx/php.conf;
  root /var/www/apc;
  allow 127.0.0.1;
  deny all;
  location / {
    access_log off;
  }
  location /nginx_status {
    stub_status on;
    access_log off;
  }
}
</pre><p>Here the included <code>/etc/nginx/php.conf</code> file is the one in which I&#8217;ve concentrate all the Nginx directives required to activate PHP file parsing. The content and the mechanism behind this file is describe in my <a href="http://kevin.deldycke.com/2011/06/nginx-php-fpm-mysql-debian-squeeze-server/">article on setting up Nginx with PHP-FPM</a>.</p><p>Let&#8217;s get back to our Munin monitoring setup. I can restart now Nginx and check that I can access locally to my raw statistics:</p><pre class="brush: bash; title: ; notranslate">
$ /etc/init.d/nginx reload
$ wget http://localhost/apc_info.php
$ wget http://localhost/nginx_status
</pre><p>The last step is to install and configure the Munin plugin:</p><pre class="brush: bash; title: ; notranslate">
$ aptitude install libwww-perl
$ wget http://munin-php-apc.googlecode.com/svn/trunk/php_apc/php_apc_ --output-document=/usr/share/munin/plugins/php_apc_
$ chmod -R 755 /usr/share/munin/plugins/
$ ln -s /usr/share/munin/plugins/php_apc_ /etc/munin/plugins/php_apc_usage
$ ln -s /usr/share/munin/plugins/php_apc_ /etc/munin/plugins/php_apc_hit_miss
$ ln -s /usr/share/munin/plugins/php_apc_ /etc/munin/plugins/php_apc_purge
$ ln -s /usr/share/munin/plugins/php_apc_ /etc/munin/plugins/php_apc_fragmentation
$ ln -s /usr/share/munin/plugins/php_apc_ /etc/munin/plugins/php_apc_files
$ ln -s /usr/share/munin/plugins/php_apc_ /etc/munin/plugins/php_apc_rates
$ echo &quot;[php_apc_*]
user root
env.url http://localhost/apc_info.php?auto
&quot; &gt; /etc/munin/plugin-conf.d/php_apc
$ /etc/init.d/munin-node restart
</pre><p>And finally, after a while, you&#8217;ll get those beautiful graphs:<br /> <a href="http://kevin.deldycke.com/wp-content/uploads/2011/06/php-apc-munin-graphs.png"><img src="http://kevin.deldycke.com/wp-content/uploads/2011/06/php-apc-munin-graphs-300x300.png" alt="" title="php-apc-munin-graphs" width="300" height="300" class="aligncenter size-medium wp-image-3347" /></a></p> ]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2011/07/php-apc-debian-squeeze-munin-monitoring/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>e107 Importer plugin for WordPress v1.4 released !</title><link>http://kevin.deldycke.com/2011/07/e107-importer-plugin-wordpress-v1-4-released/</link> <comments>http://kevin.deldycke.com/2011/07/e107-importer-plugin-wordpress-v1-4-released/#comments</comments> <pubDate>Tue, 05 Jul 2011 10:16:12 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[English]]></category> <category><![CDATA[Blog]]></category> <category><![CDATA[e107]]></category> <category><![CDATA[MySQL]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[plugin]]></category> <category><![CDATA[Web]]></category> <category><![CDATA[WordPress]]></category><guid isPermaLink="false">http://kevin.deldycke.com/?p=3374</guid> <description><![CDATA[I just released the version 1.4 of my e107 Importer plugin for WordPress. This is a special release as it ends the active development cycle. I officially declare this plugin unmaintained. I don&#8217;t plan to work on it again. The &#8230; <a href="http://kevin.deldycke.com/2011/07/e107-importer-plugin-wordpress-v1-4-released/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>I just released the version 1.4 of my <a href="http://wordpress.org/extend/plugins/e107-importer/">e107 Importer plugin for WordPress</a>.</p><p>This is a special release as it ends the active development cycle. <strong>I officially declare this plugin unmaintained</strong>. I don&#8217;t plan to work on it again.</p><p>The 1.4 will be the last version. Unless you send me code contribution, you&#8217;ll not see a 1.5 version.</p><p>The reason behind this decision is simple and straightforward: I&#8217;ve recently migrated my last e107 website to WordPress. Now that e107 is no longer part of my life, I have no interest in spending time and energy working on this plugin.</p><p>So if you plan to get rid of your e107 sites in favor of WordPress, do the migration now, as the plugin will self-deteriorate as WordPress API gets updated.</p> ]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2011/07/e107-importer-plugin-wordpress-v1-4-released/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Nginx + PHP-FPM + MySQL on a Debian Squeeze server</title><link>http://kevin.deldycke.com/2011/06/nginx-php-fpm-mysql-debian-squeeze-server/</link> <comments>http://kevin.deldycke.com/2011/06/nginx-php-fpm-mysql-debian-squeeze-server/#comments</comments> <pubDate>Tue, 28 Jun 2011 10:50:59 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[English]]></category> <category><![CDATA[Debian]]></category> <category><![CDATA[debian squeeze]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[MySQL]]></category> <category><![CDATA[nginx]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[php-fpm]]></category> <category><![CDATA[Server]]></category> <category><![CDATA[Web]]></category><guid isPermaLink="false">http://kevin.deldycke.com/?p=3253</guid> <description><![CDATA[This post is not about optimization: it only describe a sure and fast way to get all those 3 components talk to each other. This article will help you bootstrap a minimal setup, something that I wouldn&#8217;t recommend for a &#8230; <a href="http://kevin.deldycke.com/2011/06/nginx-php-fpm-mysql-debian-squeeze-server/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>This post is not about optimization: it only describe a sure and fast way to get all those 3 components talk to each other. This article will help you bootstrap a minimal setup, something that I wouldn&#8217;t recommend for a production server without serious tweaking (to get both high performances and security).</p><p>First, we&#8217;ll get all our packages from an up-to-date <a href="http://www.dotdeb.org/">DotDeb repository</a>. If this is not already done, add those repositories to aptitude:</p><pre class="brush: bash; title: ; notranslate">
$ echo &quot;deb http://packages.dotdeb.org squeeze all&quot; &gt; /etc/apt/sources.list.d/squeeze-dotdeb.list
$ gpg --keyserver keys.gnupg.net --recv-key 89DF5277
$ gpg -a --export 89DF5277 | apt-key add -
$ aptitude update
</pre><p>Now we can install the whole stack:</p><pre class="brush: bash; title: ; notranslate">
$ aptitude install nginx
$ aptitude install php5-fpm php5-mysql php5-gd php5-curl
$ aptitude install mysql-server
</pre><p>FYI, here is the list of versions I installed:</p><ul><li>Nginx 1.0.2</li><li>PHP 5.3.6</li><li>MySQL 5.1.57</li></ul><p>As a way to test that our setup is working, we&#8217;ll serve a simple PHP file:</p><pre class="brush: bash; title: ; notranslate">
$ mkdir -p /var/www/example.com/
$ cd /var/www/example.com/
$ echo &quot;
&lt;?php phpinfo(); ?&gt;
&quot; &gt; ./index.php
$ chown -R www-data:www-data /var/www
</pre><p>Now let&#8217;s create a minimal Nginx configuration file for this site:</p><pre class="brush: bash; title: ; notranslate">
$ touch /etc/nginx/sites-available/example.com
</pre><p>In this brand new file,  put the following directives:</p><pre class="brush: plain; title: ; notranslate">
server {
  server_name example.com;
  include /etc/nginx/php.conf;
  location / {
    root /var/www/example.com/;
    access_log on;
  }
}
</pre><p>This will only work if you&#8217;ve updated your DNS with an <code>A</code> record having <code>example.com</code> redirecting to the IP address of your Nginx server.</p><p>Now it&#8217;s time to create the <code>/etc/nginx/php.conf</code> file referenced in the Nginx configuration above. This file is where I put the generic setup making the bridge between Nginx and PHP-FPM. Here is what it should contain:</p><pre class="brush: plain; title: ; notranslate">
index index.php index.html index.htm;

location ~ \.php$ {
  # Zero-day exploit defense.
  # http://forum.nginx.org/read.php?2,88845,page=3
  # Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi.
  # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine.  And then cross your fingers that you won't get hacked.
  try_files $uri =404;

  fastcgi_split_path_info ^(.+\.php)(/.+)$;
  include /etc/nginx/fastcgi_params;

  # As explained in http://kbeezie.com/view/php-self-path-nginx/ some fastcgi_param are missing from fastcgi_params.
  # Keep these parameters for compatibility with old PHP scripts using them.
  fastcgi_param PATH_INFO       $fastcgi_path_info;
  fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

  # Some default config
  fastcgi_connect_timeout        60;
  fastcgi_send_timeout          180;
  fastcgi_read_timeout          180;
  fastcgi_buffer_size          128k;
  fastcgi_buffers            4 256k;
  fastcgi_busy_buffers_size    256k;
  fastcgi_temp_file_write_size 256k;

  fastcgi_intercept_errors    on;
  fastcgi_ignore_client_abort off;

  fastcgi_pass 127.0.0.1:9000;
}
</pre><p>Finally you can activate the site configuration and restart the whole stack:</p><pre class="brush: bash; title: ; notranslate">
$ ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
$ /etc/init.d/mysql restart
$ /etc/init.d/php5-fpm restart
$ /etc/init.d/nginx restart
</pre><p>If everything&#8217;s OK on your DNS, pointing your browser to <code>http://example.com</code> will show you the famous page produced by <code>phpinfo()</code>:<br /> <a href="http://kevin.deldycke.com/wp-content/uploads/2011/06/phpinfo-536.png"><img src="http://kevin.deldycke.com/wp-content/uploads/2011/06/phpinfo-536-168x300.png" alt="" title="phpinfo-536" width="168" height="300" class="aligncenter size-medium wp-image-3339" /></a></p><p>Note that MySQL doesn&#8217;t need any special attention to make it work out of the box. But again, if you plan to use it in production, its configuration needs special care, as for Nginx and PHP.</p> ]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2011/06/nginx-php-fpm-mysql-debian-squeeze-server/feed/</wfw:commentRss> <slash:comments>8</slash:comments> </item> <item><title>Configuring Fail2Ban on Debian Squeeze</title><link>http://kevin.deldycke.com/2011/06/configuring-fail2ban-debian-squeeze/</link> <comments>http://kevin.deldycke.com/2011/06/configuring-fail2ban-debian-squeeze/#comments</comments> <pubDate>Tue, 21 Jun 2011 10:25:16 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[English]]></category> <category><![CDATA[Apache]]></category> <category><![CDATA[Exim]]></category> <category><![CDATA[fail2ban]]></category> <category><![CDATA[security]]></category> <category><![CDATA[Server]]></category> <category><![CDATA[SSH]]></category> <category><![CDATA[Web]]></category><guid isPermaLink="false">http://kevin.deldycke.com/?p=3236</guid> <description><![CDATA[This always start with a package installation: Then I simply create a local configuration file where I&#8217;ll put all my custom config: Here is the content of that file: While adjusting Fail2Ban, I was surprised by how sensitive this software &#8230; <a href="http://kevin.deldycke.com/2011/06/configuring-fail2ban-debian-squeeze/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>This always start with a package installation:</p><pre class="brush: bash; title: ; notranslate">
$ aptitude install fail2ban
</pre><p>Then I simply create a local configuration file where I&#8217;ll put all my custom config:</p><pre class="brush: bash; title: ; notranslate">
$ touch /etc/fail2ban/jail.local
</pre><p>Here is the content of that file:</p><pre class="brush: plain; title: ; notranslate">
[DEFAULT]
# Do not filter connexion from my apartment and from the server itself
ignoreip  = 127.0.0.1 88.123.123.123 91.123.123.123
# Ban for a week
bantime   = 604800
maxretry  = 3
destemail = kevin@deldycke.com
banaction = iptables-allports
action    = %(action_mwl)s

[ssh]
enabled  = true
port     = 22
maxretry = 2

[ssh-ddos]
enabled = true
port     = 22

[apache]
# Apache basic auth
enabled   = true
maxretry  = 3
# Ban for 1 hour
bantime   = 3600

[apache-noscript]
enabled = true

[apache-overflows]
enabled = true

[apache-badbots]
enabled  = true
filter   = apache-badbots
port     = http,https
action   = iptables-allports
logpath  = /var/log/apache*/*access.log
maxretry = 1

[apache-nohome]
enabled  = true
filter   = apache-nohome
port     = http,https
action   = iptables-allports
logpath  = /var/log/apache*/*access.log
maxretry = 1

[exim]
enabled  = true
filter   = exim
port     = smtp,ssmtp
action   = iptables-allports
logpath  = /var/log/exim*/rejectlog
maxretry = 1

[exim-relay]
enabled  = true
filter   = exim-relay
port     = smtp,ssmtp
action   = iptables-allports
logpath  = /var/log/exim*/rejectlog
maxretry = 1
</pre><p>While adjusting Fail2Ban, I was surprised by how sensitive this software is. It can just refuse to start without any notice in the log or on the command line. Even if its <code>log_level</code> variable is set to <code>4</code> (= <code>DEBUG</code>) in <code>/etc/fail2ban/fail2ban.conf</code>.</p><p>In such a case, a sure way to find the culprit is to use a brute force debugging method: first set all the <code>enabled</code> variable of your <code>jail.local</code>&#8216;s sections to <code>false</code>. Then activate one section after another until Fail2Ban refuse to restart.</p><p>For me, the problem was that I forgot to add my custom <code>exim-relay</code> filter to Fail2Ban. So I fixed my issue by creating an empty file at <code>/etc/fail2ban/filter.d/exim-relay.conf</code> in which I pasted the following content:</p><pre class="brush: plain; title: ; notranslate">
# Based on default exim.conf filter by Cyril Jaquier
# Real life exemaple:
# 2009-07-02 08:16:42 H=118-167-129-21.dynamic.hinet.net (91.121.198.84) [118.167.129.21] F=&lt;titieueue@hotmail.com&gt; rejected RCPT &lt;s2288@mail2000.com.tw&gt;: relay not permitted

[Definition]

# Option:  failregex
# Notes.:  regex to match use of my exim mail server as a relay it does not
#          allow.
# Values:  TEXT
#
failregex = \[&lt;HOST&gt;\] .*(?:relay not permitted)

# Option:  ignoreregex
# Notes.:  regex to ignore. If this regex matches, the line is ignored.
# Values:  TEXT
#
ignoreregex =
</pre><p>Speaking of custom filters, here is one to filter DFind scans (file located at <code>/etc/fail2ban/filter.d/apache-w00tw00t.conf</code>):</p><pre class="brush: plain; title: ; notranslate">
# Based on http://howflow.com/tricks/block_w00tw00t_scan_hosts_with_fail2ban
# Real life exemaple:
# [Sat Jun 27 16:43:08 2009] [error] [client 94.23.57.77] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)

[Definition]

# Option:  failregex
# Notes.:  regex to match the w00tw00t scan messages in the logfile.
# Values:  TEXT
failregex = ^.*\[client &lt;HOST&gt;\].*w00tw00t\.at\.ISC\.SANS\.DFind.*

# Option:  ignoreregex
# Notes.:  regex to ignore. If this regex matches, the line is ignored.
# Values:  TEXT
ignoreregex =
</pre><p>And here is the corresponding section from my <code>jail.local</code> file:</p><pre class="brush: plain; title: ; notranslate">
[apache-w00tw00t]
enabled  = true
filter   = apache-w00tw00t
action   = iptables-allports
logpath  = /var/log/apache*/*error.log
maxretry = 1
</pre>]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2011/06/configuring-fail2ban-debian-squeeze/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 2/39 queries in 0.021 seconds using apc
Object Caching 1145/1238 objects using apc

Served from: kevin.deldycke.com @ 2012-02-08 03:50:10 -->
