<?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>Ball Dawg! &#187; Lighty</title>
	<atom:link href="http://www.balldawg.net/index.php/category/lighttpd/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.balldawg.net</link>
	<description>Just some ninja monkeys, nothing to see here.  Move along.</description>
	<lastBuildDate>Fri, 13 Jan 2012 02:02:53 +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>Making Your Server More Stealthy &#8211; Version Wise</title>
		<link>http://www.balldawg.net/index.php/2009/05/making-your-server-more-stealthy-version-wise/</link>
		<comments>http://www.balldawg.net/index.php/2009/05/making-your-server-more-stealthy-version-wise/#comments</comments>
		<pubDate>Thu, 28 May 2009 23:12:37 +0000</pubDate>
		<dc:creator>Andrew Rankin</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Lighty]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.balldawg.net/?p=199</guid>
		<description><![CDATA[As far as security is concerned actually advertising what software versions are running on your site is not favorable.  With most any software, whether its open source or not, if there is a bug that is exploitable and its noted on the manufacturers/projects website, there is very likely to be a version number associated with [...]]]></description>
			<content:encoded><![CDATA[<p>As far as security is concerned actually advertising what software versions are running on your site is not favorable.  With most any software, whether its open source or not, if there is a bug that is exploitable and its noted on the manufacturers/projects website, there is very likely to be a version number associated with it.  With that being the case, if your server software responds with &#8220;Apache/2.2.0&#8243; as the description of itself this can tell everyone if your a vulnerable or not.   To obfuscate this a bit I suggest setting the following items in your Apache config:</p>
<pre class="brush: shell">
ServerSignature Off
ServerTokens Prod
</pre>
<p><span id="more-199"></span></p>
<p>The first setting above will obviously turn the server signature off which is displayed at the bottom of the server generated pages &#8211; like error pages or directory listings.  The second setting will limit the HTTP response header to just include &#8220;Apache&#8221; as opposed to &#8220;Apache/2.2.0&#8243;.  There is a similar setting in lighttpd:</p>
<pre class="brush: shell">
server.tag = &quot;lighttpd&quot;
</pre>
<p>This will make the same &#8220;Server:&#8221; response header be whatever that variable is set to, in this case just &#8220;lighttpd&#8221; which again just removes the software version.</p>
<p>Along these lines is hiding that PHP actually exists on your system.  To do this changing &#8220;expose_php&#8221; within your php.ini to Off will remove any header response that you are actually running PHP.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.balldawg.net/index.php/2009/05/making-your-server-more-stealthy-version-wise/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting to lighttpd and dealing with .htaccess</title>
		<link>http://www.balldawg.net/index.php/2009/05/converting-to-lighttpd-and-dealing-with-htaccess/</link>
		<comments>http://www.balldawg.net/index.php/2009/05/converting-to-lighttpd-and-dealing-with-htaccess/#comments</comments>
		<pubDate>Fri, 08 May 2009 18:26:23 +0000</pubDate>
		<dc:creator>Andrew Rankin</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Lighty]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[proxy]]></category>

		<guid isPermaLink="false">http://www.balldawg.net/?p=28</guid>
		<description><![CDATA[I recently switched this server to Lighttpd (using PHP through FastCGI) from Apache. It was easy enough and I ended up with much faster serving websites, unfortunately I hit a snag on one of my sites that extensively uses .htaccess file for rewrites &#8211; which Lighttpd does not support. I didn&#8217;t want to bail on [...]]]></description>
			<content:encoded><![CDATA[<p>I recently switched this server to Lighttpd (using PHP through FastCGI) from Apache.  It was easy enough and I ended up with much faster serving websites, unfortunately I hit a snag on one of my sites that extensively uses .htaccess file for rewrites &#8211; which Lighttpd does not support.   I didn&#8217;t want to bail on the whole switch because of a single site, so looked and came up with a simple solution &#8211; proxy to Apache through Lighttpd for items on that site (www.350z.ws).  In lighttpds config, this was very easy to accomplish:</p>
<pre class="brush: php">
# Proxy 350z.ws back to apache
$HTTP[&quot;host&quot;] =~ &quot;www.3(5|7)0z.ws&quot; {
        $HTTP[&quot;url&quot;] !~ &quot;(wp-content|wp-includes|css|js|php$|^/blog/$)&quot; {
                proxy.server = ( &quot;/&quot; =&gt;
                        ( &quot;localhost&quot; =&gt;
                                ( &quot;host&quot; =&gt; &quot;127.0.0.1&quot;, &quot;port&quot; =&gt; 81 )
                        )
                )
        }
}
</pre>
<p>Note one (obvious) draw back is that you have to run Apache as well, but since I&#8217;m stopping most hits at Lighttpd by serving everything in wp-content, wp-includes, anything with css, js or php in the name, I can greatly reduce the number of Apaches I start and maintain.  In my case my Apache prefork config looks like this:</p>
<pre class="brush: php">
&lt;IfModule mpm_prefork_module&gt;
    StartServers          3
    MinSpareServers       2
    MaxSpareServers       5
    MaxClients          15
    MaxRequestsPerChild   10
&lt;/IfModule&gt;
</pre>
<p>You&#8217;ll also notice I&#8217;m not proxying the folder where WordPress lives back either, this is because it contains no rewrites for it specifically and will get the majority of the hits.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.balldawg.net/index.php/2009/05/converting-to-lighttpd-and-dealing-with-htaccess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Monitoring lighttpd in Xymon / Hobbit</title>
		<link>http://www.balldawg.net/index.php/2009/05/monitoring-lighttpd-in-xymon-hobbit/</link>
		<comments>http://www.balldawg.net/index.php/2009/05/monitoring-lighttpd-in-xymon-hobbit/#comments</comments>
		<pubDate>Fri, 08 May 2009 17:36:07 +0000</pubDate>
		<dc:creator>Andrew Rankin</dc:creator>
				<category><![CDATA[Hobbit / Xymon]]></category>
		<category><![CDATA[Lighty]]></category>
		<category><![CDATA[mod_status]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[rrd]]></category>
		<category><![CDATA[Server Monitoring]]></category>

		<guid isPermaLink="false">http://www.balldawg.net/?p=5</guid>
		<description><![CDATA[My employer starting using lighttpd on one layer of our architecture about a year or so ago, until now that layer has kind of been a black box to the majority of the technical staff due to not having mod_status enabled.  In preparation for it being turned on (I requested it be so after using [...]]]></description>
			<content:encoded><![CDATA[<p>My employer starting using lighttpd on one layer of our architecture about a year or so ago, until now that layer has kind of been a black box to the majority of the technical staff due to not having mod_status enabled.  In preparation for it being turned on (I requested it be so after using it on my own servers), I have created a Xymon Monitor (formally know as Hobbit) script which hits the /server-status page on the localhost and reports that data back to Xymon.  The data it reports includes requests per second and &#8220;amount increase since last script run&#8221; for the &#8220;Total KBytes&#8221; and &#8220;Total Accesses&#8221; numbers.  I also created a graph for the requests per seconds stat. </p>
<p>The Graph definition is as follows:</p>
<pre class="brush: php">
[lighttpd]
TITLE lighttpd Requests/Second
YAXIS # reqs/sec
DEF:RPS=lighttpd.rrd:reqpersec:AVERAGE
LINE2:RPS#0000CC:reqs/sec
COMMENT:
GPRINT:RPS:LAST:Requests per Second   : %5.1lf (cur)
GPRINT:RPS:MAX: : %5.1lf (max)
GPRINT:RPS:MIN: : %5.1lf (min)
GPRINT:RPS:AVERAGE: : %5.1lf (avg)
</pre>
<p><span id="more-5"></span>The Xymon scripts source code is:</p>
<pre class="brush: perl">
#!/usr/bin/perl -w
#############################################################################
# $Id: mi-lighttpd.pl 21 2009-05-07 19:22:28Z rar $
#############################################################################

use strict;
use File::Slurp;
use LWP::Simple;
use Data::Dumper;

my $port = 80;
my $bbtest = &#039;lighttpd&#039;;

#############################################################################
## BB and related test constants
#############################################################################

use constant CLEAR  =&gt; &#039;clear&#039;;
use constant GREEN =&gt;  &#039;green&#039;;
use constant YELLOW =&gt; &#039;yellow&#039;;
use constant RED    =&gt; &#039;red&#039;;
use constant PURPLE =&gt; &#039;purple&#039;;

{

#############################################################################
## Setup Variables
#############################################################################
	my $DATA    = &amp;quot;&amp;quot;;
	my $color   = GREEN;
	my $status  = $bbtest . &amp;quot; OK&amp;quot;;
	my $previous_run;
	my $current_run;
	my $restarted   = 0;
	my @delta_tests = ( &#039;total_kbytes&#039;, &#039;total_accesses&#039;, &#039;uptime&#039; );
	my @counter_tests   = ( &#039;total_accesses&#039;, &#039;total_kbytes&#039;, &#039;uptime&#039;, &#039;reqpersec&#039; );
	my @write_log;
	my $backup_log    = &amp;quot;$ENV{BBTMP}/$ENV{MACHINE}.lighttpd.data&amp;quot;;
	my %lighttpd_states = (
		&#039;_&#039; =&amp;gt; &#039;awaiting_conn&#039;,
		&#039;.&#039; =&amp;gt; &#039;connect&#039;,
		&#039;r&#039; =&amp;gt; &#039;reading_req&#039;,
		&#039;R&#039; =&amp;gt; &#039;reading_req_post&#039;,
		&#039;s&#039; =&amp;gt; &#039;sending_reply&#039;,
		&#039;S&#039; =&amp;gt; &#039;sending_reply_end&#039;,
		&#039;q&#039; =&amp;gt; &#039;request_start&#039;,
		&#039;Q&#039; =&amp;gt; &#039;request_end&#039;,
		&#039;W&#039; =&amp;gt; &#039;write&#039;,
		&#039;h&#039; =&amp;gt; &#039;handle_request&#039;,
		&#039;C&#039; =&amp;gt; &#039;close&#039;,
		&#039;E&#039; =&amp;gt; &#039;hard_error&#039;,
	);
	my %error_states = (
		&#039;reqpersec&#039; =&amp;gt; &#039;100&#039;,
		&#039;sending_reply&#039; =&amp;gt; &#039;100&#039;
	);

	my %warn_states = (
		&#039;reqpersec&#039; =&amp;gt; &#039;75&#039;,
		&#039;sending_reply&#039; =&amp;gt; &#039;75&#039;
	);

#############################################################################
## Gather previous run data &amp;amp;amp; current data
#############################################################################

	# Get Last Status
	if ( -e $backup_log ) {

		#Split Apart Data
		my @data = read_file($backup_log);
		if (@data) {
			foreach my $line (@data) {
				chomp($line);
				my ( $key, $value ) = split( /=/, $line, 2 );
				$previous_run-&amp;gt;{$key} = $value;
			}
		}
		else {
			$previous_run = 0;
		}
	}

	my $status_data = get &amp;quot;http://localhost:$port/server-status?auto&amp;quot;;

#############################################################################
## Munge the data up to get what we want
#############################################################################

	if ( defined($status_data) ) {

		my @data = split( /n/, $status_data );
		foreach my $line (@data) {
			chomp($line);
			my ( $key, $value ) = split( /: /, $line );
			$key =~ s/ /_/g;
			$key = lc($key);
			$current_run-&amp;gt;{$key} = $value;
		}

		# Create array of new values to save for our next run
		foreach ( keys %{$current_run} ) {
			push @write_log, &amp;quot;$_=$current_run-&amp;gt;{$_}n&amp;quot;;
		}

		# Calculate Incremental Data
		if ($previous_run) {
			# We need to check if we restarted here to avoid negitives
			if ($current_run-&amp;gt;{uptime} &amp;gt; $previous_run-&amp;gt;{uptime} ){
				foreach (@delta_tests) {
						$current_run-&amp;gt;{$_} = $current_run-&amp;gt;{$_} - $previous_run-&amp;gt;{$_};
				}
			}
			else {
				$status = $bbtest . &amp;quot; Restarted&amp;quot;;
				$color = YELLOW;
				$restarted = 1;
			}
		}

		# Break out scoreboard data
		foreach ( keys %lighttpd_states ) {
			$current_run-&amp;gt;{ $lighttpd_states{$_} } = 0;
		}
		foreach ( split( //, $current_run-&amp;gt;{scoreboard} ) ) {
			$current_run-&amp;gt;{ $lighttpd_states{$_} }++;
		}

		if ( !$restarted ) {
			# Get Req/Sec since last check
			$current_run-&amp;gt;{reqpersec} = sprintf &amp;quot;%.2F&amp;quot;, ( $current_run-&amp;gt;{total_accesses} / $current_run-&amp;gt;{uptime} ) if $current_run-&amp;gt;{uptime};

			## save our counter tests for the next run incase we
			## lighttpd gets restarted we have some non-zero data to send in
			foreach (@counter_tests) {
				push @write_log, &amp;quot;cur_$_=$current_run-&amp;gt;{$_}n&amp;quot;;
			}    

			# Check for warning states
			foreach ( keys %warn_states ) {
				if ( $current_run-&amp;gt;{$_} &amp;gt; $warn_states{$_} ) {
					$color  = YELLOW;
					$status = $bbtest . &amp;quot; $_ &amp;gt; $warn_states{$_}&amp;quot;;
				}
			}

			# Check for error states
			foreach ( keys %error_states ) {
				if ( $current_run-&amp;gt;{$_} &amp;gt; $error_states{$_} ) {
					$color  = RED;
					$status = $bbtest . &amp;quot; $_ &amp;gt; $error_states{$_}&amp;quot;;
				}
			}
		}
		else {
			## So we restarted, and we don&#039;t want to send nothing
			## and we don&#039;t want to send negitives on calculated tests
			## since we saved them last run for this purpose, we&#039;ll send in
			## our last run stats to keep from having huge drops in the
			## graphs.
			foreach (@counter_tests) {
				$current_run-&amp;gt;{$_} = sprintf &amp;quot;%.2F&amp;quot;, $previous_run-&amp;gt;{ &amp;quot;cur_&amp;quot;.$_ };
			}
		}

		# Delete Some Unwanted Data
		delete $current_run-&amp;gt;{scoreboard};
		delete $current_run-&amp;gt;{uptime};

		# Create Hobbit Data
		foreach ( sort keys %{$current_run} ) {
			$DATA .= &amp;quot;$_:$current_run-&amp;gt;{$_}n&amp;quot;;
		}

		# Actually Write last run file
		write_file( $backup_log, @write_log );

	}
	else {
		$status = $bbtest . &amp;quot; unable to get server-status&amp;quot;;
		$color  = CLEAR;
	}

#############################################################################
## Give data to hobbit
#############################################################################

	# hobbit formatted output
	my $report_date = `/bin/date`;
	chomp($report_date);

	## DEV DEBUG
	#print &amp;quot;$ENV{BB} $ENV{BBDISP} &#039;status apollo,xipnet,net.$bbtest $color $report_date - $statusnn$DATA&#039;n&amp;quot;;
	system(&amp;quot;$ENV{BB} $ENV{BBDISP} &#039;status apollo,xipnet,net.$bbtest $color $report_date - $statusnn$DATA&#039;n&amp;quot;);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.balldawg.net/index.php/2009/05/monitoring-lighttpd-in-xymon-hobbit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

