<?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>All things Sysadmin &#187; Webservers</title>
	<atom:link href="http://northernmost.org/blog/category/all-things-webservers/feed/" rel="self" type="application/rss+xml" />
	<link>http://northernmost.org/blog</link>
	<description>Just another manic Monday</description>
	<lastBuildDate>Thu, 18 Aug 2011 01:56:49 +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>Building Hiphop PHP gotcha</title>
		<link>http://northernmost.org/blog/building-hiphop-php-gotcha/</link>
		<comments>http://northernmost.org/blog/building-hiphop-php-gotcha/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 03:04:22 +0000</pubDate>
		<dc:creator>Erik Ljungstrom</dc:creator>
				<category><![CDATA[Sundry sysadmin]]></category>
		<category><![CDATA[Webservers]]></category>

		<guid isPermaLink="false">http://northernmost.org/blog/?p=219</guid>
		<description><![CDATA[Tonight I've delved into the world of Facebook's HipHop for PHP. Unfortunately I set about this task on an RHEL 5.4 box, and it hasn't been a walk in the park. Quite a few dependencies were out of date or didn't exist in the repositories, libicu, boost, onig, tbb etc. Though, CMake did a good job of telling me what was wrong, so it wasn't a huge deal, I just compiled the missing pieces from source and put them in $CMAKE_PREFIX_PATH. One thing CMake didn't pick up on however, was that the flex version shipped with current RHEL is rather outdated. <a href="http://northernmost.org/blog/building-hiphop-php-gotcha/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Tonight I&#8217;ve delved into the world of Facebook&#8217;s <a title="HipHop for PHP" href="http://developers.facebook.com/news.php?story=358&amp;blog=1" target="_blank">HipHop for PHP</a>. Let me early on point out that I&#8217;m not doing so because I believe that I will need it any time soon, but I am convinced  that I without a shadow of a doubt  will be approached by customers who think they do, and I rather not have opinions or advise against things I haven&#8217;t tried myself or at least have a very good understanding of.</p>
<p>Unfortunately I set about this task on an RHEL 5.4 box, and it hasn&#8217;t been a walk in the park. Quite a few dependencies were out of date or didn&#8217;t exist in the repositories, libicu, boost, onig, tbb etc.</p>
<p>Though, CMake did a good job of telling me what was wrong, so it wasn&#8217;t a huge deal, I just compiled the missing pieces from source and put them in $CMAKE_PREFIX_PATH. One thing CMake didn&#8217;t pick up on however, was that the flex version shipped with current RHEL is rather outdated. Once I thought I had everything configured, I set about the compilation, and my joy was swiftly abrupted by this:</p>
<p><code>[  3%] [FLEX][XHPScanner] Building scanner with flex /usr/bin/flex version 2.5.4<br />
/usr/bin/flex: unknown flag '-'.  For usage, try	/usr/bin/flex --help</code></p>
<p>Not entirely sure what it was actually doing here, I took the shortcut of replacing /usr/bin/flex with a shell script which just exited after putting $@ in a file in /tmp/ and re-ran `make`. Looking in the resulting file, this is the argument flex is given:</p>
<p><code>-C --header-file=scanner.lex.hpp -o/home/erik/dev/hiphop-php/src/third_party/xhp/xhp/scanner.lex.cpp /home/erik/dev/hiphop-php/src/third_party/xhp/xhp/scanner.l</code></p>
<p>To me that looks quite valid, and there&#8217;s certainly no single &#8211; in that command line.</p>
<p>Long story short, flex introduced &#8211;header-file in a relatively &#8220;recent&#8221; version (2.5.33 it seems, but I may be wrong on that one, doesn&#8217;t matter). Unlike most other programs (using getopt), it won&#8217;t tell you &#8220;Invalid option &#8216;&#8211;header-file&#8217;&#8221;. So after compiling a newer version of flex, I was sailing again.</p>
]]></content:encoded>
			<wfw:commentRss>http://northernmost.org/blog/building-hiphop-php-gotcha/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Multiple backends with Varnish</title>
		<link>http://northernmost.org/blog/multiple-backends-with-varnish/</link>
		<comments>http://northernmost.org/blog/multiple-backends-with-varnish/#comments</comments>
		<pubDate>Mon, 15 Sep 2008 23:25:54 +0000</pubDate>
		<dc:creator>Erik Ljungstrom</dc:creator>
				<category><![CDATA[misc]]></category>
		<category><![CDATA[Webservers]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[load balancing]]></category>
		<category><![CDATA[varnish]]></category>

		<guid isPermaLink="false">http://northernmost.org/blog/?p=123</guid>
		<description><![CDATA[So as of now, you can safely use one varnish instance for several front-ends, thus eliminate double-caching (memory waste, unnecessary load on back-ends), reduce network traffic, do rudimentary load balancing, ease management etc.
With the obscene amount of traffic Varnish can push without putting a fairly basic system under any load worth mentioning, you can use a single front-end to serve several nodes in most setups. <a href="http://northernmost.org/blog/multiple-backends-with-varnish/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://varnish.projects.linpro.no/">Varnish</a> has been able to provide caching for more than one backend for quite some time. The achilles heel with this has up until now been that it hasn&#8217;t been able to determine whether a backend is healthy or not. This is now a problem of the past! The backend health polling code is available in <a href="http://sourceforge.net/project/showfiles.php?group_id=155816">2.0 beta1</a> Sadly it had a bug, so when using the &#8216;random&#8217; director, it was unable to use the remaining healthy backend if all but one went MIA. I reported this <a href="http://varnish.projects.linpro.no/ticket/306">bug</a> and it was fixed in changeset r3174. </p>
<p>So as of now, you can <strong>safely</strong> use one varnish instance for several front-ends, thus eliminate double-caching (memory waste, unnecessary load on back-ends), reduce network traffic, do rudimentary load balancing, ease management etc.<br />
With the obscene amount of traffic Varnish can push without putting a fairly basic system under any load worth mentioning, you can use a single front-end to serve several nodes in most setups.</p>
<p>Here&#8217;s an elementary sample VCL for how to do this:</p>
<pre>backend node0 {
  .host = "127.0.0.1";
  .port = "80";
  .probe = {
           .url = "/";
           .timeout = 50 ms;
           .interval = 1s;
           .window = 10;
           .threshold = 8;

  }
}

backend node1 {
  .host = "10.0.0.2";
  .port = "80";
  .probe = {
#           .url = "/";
           .timeout = 100 ms;
           .interval = 1s;
           .window = 10;
           .threshold = 8;
        .request =
            "GET /healthcheck.php HTTP/1.1"
            "Host: 10.0.0.2"
            "Connection: close"
            "Accept-Encoding: foo/bar" ;
  }
}
director cl1 random {
    { .backend = node0; .weight = 1; }
    { .backend = node1; .weight = 1; }
}

#director cl1 round-robin {
#   { .backend = node1; }
#   { .backend = node0; }
#}

sub vcl_recv {
        set req.backend = cl1;
}</pre>
<p><br/><br />
As you can see I&#8217;m defining the backends slightly differently. You need to define one of .url or .request, but not both for obvious reasons. If you go for the slighly simpler .url the default request looks like this:</p>
<pre>GET / HTTP/1.1
Host: something
Connection: close
</pre>
<p><br/></p>
<p>If this does not suit your need, comment out .url and use .request to roll your own. This aspect of Varnish is actually quite well documented, so I won&#8217;t repeat what&#8217;s on the <a href="http://varnish.projects.linpro.no/wiki/BackendPolling">trac page</a>.</p>
<p>There is clearly a lot more you can and, more often than not, should do in the VCL than the above. This is a stripped down version which only pertains to the backend polling functionality. </p>
]]></content:encoded>
			<wfw:commentRss>http://northernmost.org/blog/multiple-backends-with-varnish/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>lighttpd 2.0</title>
		<link>http://northernmost.org/blog/lighttpd-20/</link>
		<comments>http://northernmost.org/blog/lighttpd-20/#comments</comments>
		<pubDate>Sat, 02 Aug 2008 23:41:40 +0000</pubDate>
		<dc:creator>Erik Ljungstrom</dc:creator>
				<category><![CDATA[Webservers]]></category>
		<category><![CDATA[lighttpd]]></category>

		<guid isPermaLink="false">http://northernmost.org/blog/?p=35</guid>
		<description><![CDATA[While I've experienced some of the "oddities" they refer to, I have every bit of confidence in the developers. Even so - it's a risky path to go down. They will most likely iron out the current shortcomings and oddities, but it's fairly likely that a few new will be introduced during the course of rewriting. 
 <a href="http://northernmost.org/blog/lighttpd-20/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Linked from a <a href="http://blog.lighttpd.net/articles/2008/07/23/a-new-beginning/">post</a> on the lighttpd blog is a page outlining the <a href="http://redmine.stbuehler.de/wiki/lighttpd-sandbox/Plans_for_2_0">plans for lighttpd 2.0</a></p>
<p>While I&#8217;ve experienced some of the &#8220;oddities&#8221; they refer to, I have every bit of confidence in the developers. Even so &#8211; it&#8217;s a risky path to go down. They will most likely iron out the current shortcomings and oddities, but it&#8217;s fairly likely that a few new will be introduced along the way. I do however believe the planned use of the well proven glib is likely to prevent some of them.</p>
<p>It will be mighty interesting to see the impact of using <a href="http://software.schmorp.de/pkg/libev.html">libev</a> for managing events. It certainly helps when &#8220;flying light&#8221;. Another interesting thing will be to see what plugins people come up with!</p>
<p>Graceful restarts will be most welcomned as well!</p>
<p>Go go lighttpd!</p>
]]></content:encoded>
			<wfw:commentRss>http://northernmost.org/blog/lighttpd-20/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mod_log_forensic howto</title>
		<link>http://northernmost.org/blog/mod_log_forensic-howto/</link>
		<comments>http://northernmost.org/blog/mod_log_forensic-howto/#comments</comments>
		<pubDate>Sun, 24 Feb 2008 01:21:06 +0000</pubDate>
		<dc:creator>Erik Ljungstrom</dc:creator>
				<category><![CDATA[Sundry sysadmin]]></category>
		<category><![CDATA[Webservers]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[mod_log_forensics]]></category>
		<category><![CDATA[mod_unique_id]]></category>

		<guid isPermaLink="false">http://northernmost.org/blog/mod_log_forensic-howto/</guid>
		<description><![CDATA[mod_log_forensic is an often forgotten yet very handy tool in debugging webservers. It gives each request a unique ID which you can then track through your log. It first writes the request prefixed with the unique ID, then it writes &#8230; <a href="http://northernmost.org/blog/mod_log_forensic-howto/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://httpd.apache.org/docs/2.2/mod/mod_log_forensic.html">mod_log_forensic</a> is an often forgotten yet very handy tool in debugging webservers. It gives each request a unique ID which you can then track through your log. It first writes the request prefixed with the unique ID, then it writes the same ID once the request is completed. Very useful to spot scripts which never finishes, be it due to client or server issues. You see the entire request including browser information,  cookies etc. Like this:</p>
<p><code>+sS6NLH8AAAEAAHoSUdUAAAAB|GET /favicon.ico HTTP/1.1|User-Agent:Opera/9.26 (Windows NT 5.1; U; en)|Host:northernmost.org|Accept:text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1|Accept-Language:en-GB,en;q=0.9|Accept-Charset:iso-8859-1, utf-8, utf-16, *;q=0.1|Accept-Encoding:deflate, gzip, x-gzip, identity, *;q=0|Referer:http%3a//northernmost.org/test.html|Connection:Keep-Alive, TE|TE:deflate, gzip, chunked, identity, trailers<br />
-sS6NLH8AAAEAAHoSUdUAAAAB<br />
</code></p>
<p>When investigating the logs, you usually want to look for any +&lt;ID&gt; without a corresponding -&lt;ID&gt;, that means that that request was never finalised. You can then look through the script/file in question and see what may have gone wrong.</p>
<p>mod_log_forensic is included in most distribution packages of Apache and comes with the source tarball download, but if you compile Apache 2.x.x from source, you need to add <code>--enable-log-forensic and --enable-unique-id </code>to the configure line.</p>
<p> In httpd.conf, you will need to have the following lines (preferably in their respective context):</p>
<p><code>LoadModule log_forensic_module modules/mod_log_forensic.so<br />
LoadModule unique_id_module modules/mod_unique_id.so<br />
ForensicLog logs/forensic_log</code></p>
<p>If you want, you can have the request ID added to your normal access_log as well by simply editing the LogFormat to look something along the lines of:</p>
<p><code>LogFormat "%{forensic-id}n %h %l %u %t \"%r\" %&gt;s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined</code></p>
<p>Note that this will most likely break any log-based webstats package you might be using, such as awstats, webalizer etc.</p>
<p>There is a tool supplied with the source distribution of Apache called check_forensic which takes the forensics log as input and outputs any inomplete request. If I for instance were to remove -sS6NLH8AAAEAAHoSUdUAAAAB line from /var/log/httpd/forensics_log, I&#8217;d get this from a run:</p>
<p><code># sh check_forensic /var/log/httpd/forensic_log<br />
+sS6NLH8AAAEAAHoSUdUAAAAB|GET /favicon.ico HTTP/1.1|User-Agent:Opera/9.26 (Windows NT 5.1; U; en)|Host:northernmost.org|Accept:text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1|Accept-Language:en-GB,en;q=0.9|Accept-Charset:iso-8859-1, utf-8, utf-16, *;q=0.1|Accept-Encoding:deflate, gzip, x-gzip, identity, *;q=0|Referer:http%3a//northernmost.org/test.html|Connection:Keep-Alive, TE|TE:deflate, gzip, chunked, identity, trailers</code></p>
<p>You would however have rather serious issues if you had failed requests for favicon.ico ;) Another overlooked useful module you might want/need to use in combination with mod_log_forensic is <a href="http://people.apache.org/~trawick/mod_whatkilledus.c">mod_whatkilledus</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://northernmost.org/blog/mod_log_forensic-howto/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP 5.1 and 5.2 and MySQL 5.1.20+</title>
		<link>http://northernmost.org/blog/php-51-and-52-and-mysql-5120/</link>
		<comments>http://northernmost.org/blog/php-51-and-52-and-mysql-5120/#comments</comments>
		<pubDate>Fri, 22 Feb 2008 22:01:04 +0000</pubDate>
		<dc:creator>Erik Ljungstrom</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Webservers]]></category>
		<category><![CDATA[compile errors]]></category>
		<category><![CDATA[gptr]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysqli]]></category>

		<guid isPermaLink="false">http://northernmost.org/blog/php-51-and-52-and-mysql-5120/</guid>
		<description><![CDATA[Today I fell victim of a gotcha when custom compiling PHP 5.1.4 for a customer which runs MySQL 5.1.22. The customer in question requires the mysqli component which appears to be broken with these versions (fixed in 5.2.4 though). So &#8230; <a href="http://northernmost.org/blog/php-51-and-52-and-mysql-5120/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Today I fell victim of a gotcha when custom compiling PHP 5.1.4 for a customer which runs MySQL 5.1.22. The customer in question requires the mysqli component which appears to be broken with these versions (fixed in 5.2.4 though).  So if you configure PHP with <code>--with-mysqli=/usr/bin/mysql_config</code> enabled you will soon find yourself staring at:</p>
<p><code>/usr/local/src/php-5.1.4/ext/mysqli/mysqli_api.c: In function 'zif_mysqli_stmt_bind_param':<br />
/usr/local/src/php-5.1.4/ext/mysqli/mysqli_api.c:145: error: 'gptr' undeclared (first use in this function)<br />
/usr/local/src/php-5.1.4/ext/mysqli/mysqli_api.c:145: error: (Each undeclared identifier is reported only once<br />
/usr/local/src/php-5.1.4/ext/mysqli/mysqli_api.c:145: error: for each function it appears in.)<br />
/usr/local/src/php-5.1.4/ext/mysqli/mysqli_api.c: In function 'zif_mysqli_stmt_execute':<br />
/usr/local/src/php-5.1.4/ext/mysqli/mysqli_api.c:601: error: 'gptr' undeclared (first use in this function) </code></p>
<p>To fix this, either upgrade to 5.2.4, or if you&#8217;re left with no choice such as myself edit  <font face="Courier New">php-5.1.4/ext/mysqli/mysqli_api.c </font> and replace all occurrances of <code>gptr </code>with <code>char* </code></p>
<p>That ought to get you through the rest of the compilation provided that you&#8217;ve got the rest of your setup correct.</p>
]]></content:encoded>
			<wfw:commentRss>http://northernmost.org/blog/php-51-and-52-and-mysql-5120/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Hacked webapps</title>
		<link>http://northernmost.org/blog/hacked-webapps/</link>
		<comments>http://northernmost.org/blog/hacked-webapps/#comments</comments>
		<pubDate>Fri, 22 Feb 2008 01:27:22 +0000</pubDate>
		<dc:creator>Erik Ljungstrom</dc:creator>
				<category><![CDATA[Webservers]]></category>
		<category><![CDATA[joomla]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[script kiddies]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[webapps]]></category>

		<guid isPermaLink="false">http://northernmost.org/blog/hacked-webapps/</guid>
		<description><![CDATA[Disclaimer: I say ‘hack’ and ‘hacker’, both you jargon puritans out there and myself know they’re not. Really. But it’s a short and easy to spell word and with this disclaimer, everyone will know what I mean. Including the audience &#8230; <a href="http://northernmost.org/blog/hacked-webapps/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Disclaimer: I say ‘hack’ and ‘hacker’, both you jargon puritans out there and myself know they’re not. Really. But it’s a short and easy to spell word and with this disclaimer, everyone will know what I mean. Including the audience I mainly target with this post!</p>
<p>This post might not be very relevant to the audience I mainly write this blog for, but if it can save me or someone else with on-call duties just one sleepless night, it’ll be worth it!</p>
<p>Today it happened again. At 2 am an SMS message from our beloved friend and saviour NetFlow woke me up from my much needed beauty sleep. 120 000 outbound packets per second from a customer&#8217;s machine. Null routed, great! As I made my way to the datacenter I thought “I bet it’s another one of those web-hack”</p>
<p>So I figured I should write about it here in hope that some web hoster (a lot of our customers are) reads this and clocks on!</p>
<p>The ‘hack’ was indeed a classic one, a non-patched/outdated Joomla install with a cross-site scripting vulnerability. This post will only rant about this particular type of intrusion, and by no means web app hacks in general, although most of it will be useful in other contexts as well.</p>
<p>I think there are somewhere around 19 different worms/scanners for Joomla out in the wild. I’m guessing it’s because the installation requires some knowledge of apache, php and elementary understanding of access control. Almost more often than not, I see these installations ending up with register_globals turned on, allow_url_fopen turned on, safe_mode off and chmod -R 777 /var/www/</p>
<p>Brilliant, isn&#8217;t it?</p>
<p>Since 9 out of 10 hacks we’ve seen lately happens due to insecure web applications which typically run as the Apache user which has limited write privileges, the first thing I do when investigating a hacked server is:</p>
<p><code>ls -al /tmp ; ls -al /var/tmp </code></p>
<p>This is a popular place for script kiddies to put their (read other people’s) scripts of doom. Nothing there! It was now clear to me that I was dealing with a mighty level 2 script kiddie!</p>
<p>So I ran:</p>
<p><code>find /var/www/htdocs/ -name "*.php" | xargs grep -i r57 &gt; /root/r57</code></p>
<p>r57 is the spawn of satan on your harddrive. It’s a single-file PHP script which allows you to do pretty much everything you would if you had shell access with the permissions of apache (you technically do since you’ve even got a command line). It’s got a database section which allows you to dump databases and run arbitrary queries, an FTP interface for uploading and downloading files, a callback functionality etc. In a nutshell; not something you’ll want anywhere under your DocumentRoot! Turns out the 120 000 packets per second originated from a script hidden well inside the directory structure of the site called ‘udp.pl’. This was downloaded and executed through the r57 shell. Another drawback of 777 permissions, files such as those can be hidden anywhere!</p>
<p>So, in order to stop this particular type hack, you’d want to keep your privileges strict! Do not allow apache to write anywhere where it’s not strictly necessary! Although I do realise that some directories requires write permissions if you think (S)FTP is too much like voodoo to get your images onto your site, most directories don’t!</p>
<p>The second thing is to disable some of the functions these scripts love to use. In your php.ini (php -i |grep .ini will tell you where it is), find the line starting with disable_functions, and make it look like this:</p>
<p><code>disable_functions = system,exec,execl,shell_exec,passthru,ftp_login,popen</code></p>
<p>r57 and its derivatives (c99 etc.) needs these to do most of its tasks. Since these scripts has a front-end for emailing, in order to prevent ending up in a handful of blacklists, you could add ‘mail’ to the list as well if your website doesn’t need to send emails or use a socket based solution (a la phpmailer). If at all possible, you will want open_basedir and safe_mode enforcing! register_globals should be Off as well. If it requires you to rewrite part of your website to cater for this, you still might want to consider it. It could save you a lot of work in the future. The above mentioned customer had 6 hours of downtime during a reinstall and checking over their scripts (their backups were contaminated as well and the above command does obviously not find everything malicious!).</p>
<p>Another PHP setting you should turn off if possible is allow_url_fopen which basically means that if your webapp doesn’t do proper input validation and opens a file requested by a user, a URL could be passed instead of a local file! The URL could contain a script which the visitor then can use to do as he wishes.</p>
<p>But, the number one precaution; write good code!</p>
<p>Another useful thing you can do to if you suspect there’s been some foul play going on is:</p>
<p><code>netstat -tpanu |grep 666[78]</code></p>
<p>which will tell you if there are any in- or outbound IRC connections from the server. If there are, it is quite likely that it’s compromised as a majority of hacks are made by script kiddies looking for a place to put their IRC bots.</p>
<p>Well, I should say, a majority of the hacks that are discovered are.</p>
<p>Keeping track of your bandwidth consumption and webstats is useful as well as a lot of hacked servers acts as filedumps for less able warez groups. If you one month see a 40% increase in bandwidth usage, but no corresponding increase in hits, you either have an employee taking liberties, or a 14 year old doing the same from his home PC.</p>
<p>If your site is fairly static in terms of files in the directory structure, you can use ‘find’ to list all files created after a certain date. If you haven’t uploaded these, chances are above mentioned 14 year old has. This command will show you all files which has been modified in the last 24 hours:</p>
<p><code>find /var/www/htdocs/ -type f -mtime -1</code></p>
<p>So, to sum up; As a very basic start; write proper code, restrict filesystem permissions, enable open_basedir and safe_mode, turn allow_url_fopen off, apply the above mentioned disable_functions and disable register_globals.</p>
<p>There are obviously a lot more you can do than the above, those are just the very basics! If you want to go a bit more hardcore, you could look into running PHP as CGI with proper OS level user separation, using SuExec, noexec mounted  partitions, chroot environments etc. But that’s perhaps another post!</p>
]]></content:encoded>
			<wfw:commentRss>http://northernmost.org/blog/hacked-webapps/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Apache gotcha with ServerLimit</title>
		<link>http://northernmost.org/blog/apache-gotcha-with-serverlimit/</link>
		<comments>http://northernmost.org/blog/apache-gotcha-with-serverlimit/#comments</comments>
		<pubDate>Wed, 20 Feb 2008 04:20:13 +0000</pubDate>
		<dc:creator>Erik Ljungstrom</dc:creator>
				<category><![CDATA[Webservers]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[MaxClients]]></category>
		<category><![CDATA[ServerLimit]]></category>

		<guid isPermaLink="false">http://northernmost.org/blog/apache-gotcha-with-serverlimit/</guid>
		<description><![CDATA[A little gotcha that happened to me a while ago; A rather sizeable customer had just launched a new campaign and had problems with HTTP content matching alerts being thrown rather frequently. This particular solution has got five loadbalanced webservers &#8230; <a href="http://northernmost.org/blog/apache-gotcha-with-serverlimit/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A little gotcha that happened to me a while ago; A rather sizeable customer had just launched a new campaign and had problems with HTTP content matching alerts being thrown rather frequently.</p>
<p>This particular solution has got five loadbalanced webservers and two database back-ends designed to cater for a reasonably high amount of traffic and shorter bursts of traffic surges.</p>
<p>The servers did not seem to be under any particular load, and I could connect to localhost just fine (telnet is a magnificent troubleshooting tool, is it not?). I looked at the cacti graphs on all four servers in the cluster, and noticed in the apache scoreboard that there were more or less exactly 256 threads running on all five servers. `ps ax|grep httpd | wc -l`confirmed this. So I went and edited httpd.conf and raised ServerLimit and MaxClients to 750 (from 256).</p>
<p>Then here&#8217;s my mistake &#8211; being the nice guy that I am &#8211; I did /usr/local/apache/bin/apachectl graceful . But got this in error_log:</p>
<p>WARNING: MaxClients of 750 exceeds ServerLimit value of 256 servers,lowering MaxClients to 256. To increase, please see the ServerLimit directive.</p>
<p>Hm, why would maxclients be respected, but not serverlimit? Short answer is; when doing graceful, the parent apache uber-process is not killed and restarted and this value can not be changed without a full blown restart. Pretty obvious once you know about it! I sifted through apachectl, and all it did was:&#8230;</p>
<p>case $ARGV instart|stop|restart|graceful|graceful-stop)<br />
$HTTPD -k $ARGV ERROR=$? ;;</p>
<p>&#8230;so obviously an `apachectl restart` would not be sufficient either. So long story short, when changing the ServerLimitdirective, a graceful-stop and a start is necessary! At least this is true for this custom compiled apache 2.2.3.</p>
]]></content:encoded>
			<wfw:commentRss>http://northernmost.org/blog/apache-gotcha-with-serverlimit/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Highly unscientific comparison of webservers</title>
		<link>http://northernmost.org/blog/highly-unscientific-comparison-of-webservers/</link>
		<comments>http://northernmost.org/blog/highly-unscientific-comparison-of-webservers/#comments</comments>
		<pubDate>Wed, 20 Feb 2008 04:05:52 +0000</pubDate>
		<dc:creator>Erik Ljungstrom</dc:creator>
				<category><![CDATA[Sundry sysadmin]]></category>
		<category><![CDATA[Webservers]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[benchmark]]></category>
		<category><![CDATA[comparison]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://northernmost.org/blog/highly-unscientific-comparison-of-webservers/</guid>
		<description><![CDATA[A while ago a customer asked us to perform some benchmarks which would be applicable to their live application. The webservers in question are Apache, lighttpd and nginx The tests were made using apachebench on two dedicated machines with no &#8230; <a href="http://northernmost.org/blog/highly-unscientific-comparison-of-webservers/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://northernmost.org/blog/wp-content/uploads/2008/02/webservers_bench.jpg"><img src="http://northernmost.org/blog/wp-content/uploads/2008/02/webservers_bench.thumbnail.jpg" alt="Websever Benchmark Results" /></a><br />
A while ago a customer asked us to perform some benchmarks which would be applicable to their live application. The webservers in question are <a href="http://www.apache.org/httpd">Apache</a>, <a href="http://www.lighttpd.net">lighttpd</a> and <a href="http://nginx.net">nginx</a></p>
<p>The tests were made using apachebench on two dedicated machines with no other tasks and over a dedicated 100 mbit network. Some figures really surprises me/strikes me as odd, such as the varied php performance of lighttpd utilising fastcgi!</p>
<p>I suppose it would only have been fair to test apache with fastcgi as well, but thatwas out of scope for their request.Should you be interested in the full AB output, you can download a tarball containing all the data <a href="http://northernmost.org/files/webserver_benchmark.tar.gz">here</a>. See attachment for diagrams and figures.</p>
]]></content:encoded>
			<wfw:commentRss>http://northernmost.org/blog/highly-unscientific-comparison-of-webservers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

