Lighttpd

Compiling Lighttpd from source
yum install gcc pcre-devel openssl-devel mysql-devel bzip2-devel wget http://www.lighttpd.net/download/lighttpd-1.4.20.tar.gz tar -xzf lighttpd-1.4.20.tar.gz cd lighttpd-1.4.20 ./autogen.sh && ./configure && make echo $? ./autogen.sh && ./configure --with-openssl --with-openssl-libs=/usr/lib/openssl && make echo $? make install
 * Installing Prerequisites
 * Downloading and untaring
 * Compiling Lighttpd
 * Compiling Lighttpd with SSL
 * Installing Lighttpd

Running SSL and insecure setups
$SERVER["socket"] == ":80" { server.document-root      = "/var/www/lighttpd/redirect/" } $SERVER["socket"] == ":443" { ssl.engine                = "enable" ssl.pemfile               = "//example.com.pem" server.document-root      = "/var/www/lighttpd/" }
 * In /etc/lighttpd/lighttpd.conf 
 * 1) Redirect HTTP requests to HTTPS

Redirecting all insecure requests to the SSL port
The below configuration will redirect all web traffic sent for port 80 to port 443, by asking the client's browser to use the port 443 instead. This configuration will apply to all domains on this server. Add "mod_redirect" to the server.modules section on the top then further down add: $SERVER["socket"] == ":80" { $HTTP["host"] =~ "(.*)" { url.redirect = ( "^/(.*)" => "https://%1/$1" ) } }
 * In /etc/lighttpd/lighttpd.conf

Securing a web directory with a password
auth.backend               = "htpasswd" auth.backend.htpasswd.userfile = "/etc/lighttpd/htpasswords" auth.require = ( "/noc/" =>                 ( "method"   => "basic", "realm"    => "example.com", "require"  => "valid-user" )              )
 * In /etc/lighttpd/lighttpd.conf 
 * 1) Authication Module - Using htpasswd from Apache

Enabling System Status & System Configuration Pages
(See Securing a web directory with a password above for more information on secure a page
 * In /etc/lighttpd/lighttpd.conf 

Start by enabling mod_status under the server.modules section. "mod_status", Then allow access to the corresponding pages: auth.require              = ( "/server-status" =>                               ( "method" => "basic", "realm"  => "mail.mattrude.com", "require" => "valid-user" ),                               "/server-config" =>                               ( "method" => "basic", "realm"  => "mail.mattrude.com", "require" => "valid-user" )                            )

Lighttpd's init files
# # # # . /etc/rc.d/init.d/functions if [ -f /etc/sysconfig/lighttpd ]; then . /etc/sysconfig/lighttpd fi if [ -z "$LIGHTTPD_CONF_PATH" ]; then LIGHTTPD_CONF_PATH="/etc/lighttpd/lighttpd.conf" fi prog="lighttpd" lighttpd="/usr/local/sbin/lighttpd" RETVAL=0 start { echo -n $"Starting $prog: " daemon $lighttpd -f $LIGHTTPD_CONF_PATH RETVAL=$? echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog return $RETVAL } stop { echo -n $"Stopping $prog: " killproc $lighttpd RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog return $RETVAL } reload { echo -n $"Reloading $prog: " killproc $lighttpd -HUP RETVAL=$? echo return $RETVAL } case "$1" in 	start) 		start 		;; 	stop) stop ;; 	restart) 		stop 		start 		;; 	condrestart) if [ -f /var/lock/subsys/$prog ]; then stop start fi ;; 	reload) 		reload 		;; 	status) status $lighttpd RETVAL=$? ;; 	*) 		echo $"Usage: $0 {start|stop|restart|condrestart|reload|status}" 		RETVAL=1 esac exit $RETVAL LIGHTTPD_CONF_PATH=/etc/lighttpd/lighttpd.conf echo "lighttpd:x:493:492:lighttpd web server:/var/www/lighttpd:/sbin/nologin" >> /etc/passwd echo "lighttpd:x:492:" >> /etc/group mkdir /etc/lighttpd chown lighttpd:lighttpd /etc/lighttpd mkdir /var/run/lighttpd chown lighttpd:lighttpd /var/run/lighttpd mkdir /var/log/lighttpd chown lighttpd:lighttpd /var/log/lighttpd
 * /etc/init.d/lighttpd
 * 1) !/bin/sh
 * 1) lighttpd     Startup script for the lighttpd server
 * 1) chkconfig: - 85 15
 * 2) description: Lightning fast webserver with light system requirements
 * 1) processname: lighttpd
 * 2) config: /etc/lighttpd/lighttpd.conf
 * 3) config: /etc/sysconfig/lighttpd
 * 4) pidfile: /var/run/lighttpd.pid
 * 1) Note: pidfile is assumed to be created
 * 2) by lighttpd (config: server.pid-file).
 * 3) If not, uncomment 'pidof' line.
 * 1) Source function library
 * /etc/sysconfig/lighttpd
 * Setup