server.modules = (
	"mod_access",
	"mod_accesslog",
	"mod_alias",
#	"mod_deflate",
	"mod_redirect",
	"mod_rewrite",
	"mod_openssl",
	"mod_proxy"
)

server.document-root = "/srv/www"
server.upload-dirs = ( "/var/cache/lighttpd/uploads" )
server.errorlog = "/var/log/lighttpd/error.log"
server.pid-file = "/run/lighttpd.pid"
server.username = "www-data"
server.groupname = "www-data"

#tweaks om die rare upload dir te temen
server.stream-request-body = 2
server.stream-response-body = 2

accesslog.filename = "/var/log/lighttpd/access.log"

index-file.names = ( "index.php", "index.html", "index.lighttpd.html" )
url.access-deny = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

#compress.cache-dir = "/var/cache/lighttpd/compress/"
#compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" )

dir-listing.encoding = "utf-8"
server.dir-listing = "enable"

server.bind = "145.24.129.36"
server.follow-symlink = "enable"
server.max-connections = 2048
server.max-fds = 8192

server.http-parseopts = (
  "header-strict"           => "enable",# default
  "host-strict"             => "enable",# default
  "host-normalize"          => "enable",# default
  "url-normalize-unreserved"=> "enable",# recommended highly
  "url-normalize-required"  => "enable",# recommended
  "url-ctrls-reject"        => "enable",# recommended
  "url-path-2f-decode"      => "disable",# recommended highly (unless breaks app)
 #"url-path-2f-reject"      => "enable",
  "url-path-dotseg-remove"  => "disable",# recommended highly (unless breaks app)
 #"url-path-dotseg-reject"  => "enable",
 #"url-query-20-plus"       => "enable",# consistency in query string
)

dir-listing.exclude = ("^lost\+found$", "^\.hrlogo\.png$", "^favicon\.ico$")

# http
$SERVER["socket"] == "145.24.129.36:80"  {

        # default site een blanco site (op ip)
        server.document-root = "/srv/www"

	# sites mirror.hr.nl en mirror.hro.nl
	$HTTP["host"] =~ "^(aptproxy\.hro?\.nl|debian\.hro?\.nl|mirror\.hro?\.nl|kernel\.hro?\.nl|www\.debian\.hro?\.nl|www\.kernel\.hro?\.nl|www\.mirror\.hro?\.nl|http\.debian\.hro?\.nl|http\.kernel\.hro?\.nl|http\.mirror\.hro?\.nl)$" {
		server.document-root = "/srv/ftp"
		accesslog.filename = "/var/log/lighttpd/mirror.hr.nl-access.log"
		dir-listing.set-footer = "<b>mirror.hr.nl</b> hosted by <a href='https://www.rotterdamuas.com/' style='border-style: none;'><img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAYCAYAAAAPtVbGAAACQUlEQVRIib2WQUhTcRzHP1vG5qabsaRShxOzOiwWo0OXwYhOZZh4SKmgiFq38hJBh7IQArEhBdWlomDqQTCU8OBh4ckOahiUrDCdsdzjsTl17rWxdZCtPffUDZzf6+/3/35+3/fj/95TpVIpvlacvwC4AQs7ozDQbg0PvVWpVKimjY1XgTc7ZL5RzceXhgfVrCcoltwAaqCiiBBLGlJ05Q1RmzWYHpyh2uMqGFKST5OuqZaqh7fR1jUAsHLrM8ZzpzE4nACIfb0sdg6Q9EvKA25nXu1xoS4vzQAAzE8eZQAAptY2jBdPFpZk7wkDhx7fyBiF+ke2mmV9Wn1pfhC1WcOB+y2YWttyGmecl9BYq7A871I0Sq6uyXyyH50McsT7ghJTpexwQhSITfwh6ZfQnarfdNqV0WkAyi4fI7m8RtQ/9x+a3Sgt+HMOB7qekfRLqM0aKl1XFAEBdw/xqQi6plpqOu4SnwvJ6rIksW8z6G12WUPs+28AtPaDsuVnS3u0nrpPDvQ2O2JfL/GpiKwuSxL7McdG7b/ZzOHJp4rmae0724jeZichCix2DuTUZUkk34KiQT5KiAKz1+8p3hVZkuiH3CRpaRpqCH0cVqxFxrz8bLmD5A0q1nPuyeqXCdleYrM+hFfvWXo5SdTpY095GQaHk4QosDw+Tqh/ZMvhFCHp5SdEAeGdB7FjNFOTvEHmvd1A95am20L+BoIE3D2EXo9t+i4qVDmQ7Ml3Srv2Pfm1G5D2okOs4aFB4BrrvzFF0T8R273MWh/oegAAAABJRU5ErkJggg==' alt='HR' style='vertical-align: middle; border-style: none;' /></a> <a href='https://www.hogeschoolrotterdam.nl/' style='color: #787878; font-weight: bold;'>Hogeschool Rotterdam</a> / <a href='https://www.rotterdamuas.com/' style='color: #787878; font-weight: bold;'>Rotterdam University of Applied Sciences</a><img src='http://piwik.hro.nl/piwik.php?idsite=2&rec=1' style='border:0' alt='' />"
		url.rewrite-once = ("^/favicon.ico$" => "/hro/favicon.ico")

		$HTTP["remoteip"] == "145.24.0.0/16" {
			alias.url += ( "/hrdeb" => "/srv/hrdeb/" )
			$HTTP["host"] == "aptproxy.hro.nl" {
				proxy.server = ( "" => ( ( "host" => "127.0.0.1", "port" => "3142" ) ) )
			}
		}

		$HTTP["remoteip"] == "145.51.0.0/16" {
			alias.url += ( "/hrdeb" => "/srv/hrdeb/" )
			$HTTP["host"] == "aptproxy.hro.nl" {
				proxy.server = ( "" => ( ( "host" => "127.0.0.1", "port" => "3142" ) ) )
			}
		}

		# Toegang voor tasarov
		$HTTP["remoteip"] == "46.19.32.138" { 
			alias.url += ( "/hrdeb" => "/srv/hrdeb/" )
			$HTTP["host"] == "aptproxy.hro.nl" {
				proxy.server = ( "" => ( ( "host" => "127.0.0.1", "port" => "3142" ) ) )
			}
		}
	}
}

# https
$SERVER["socket"] == "145.24.129.36:443"  {

	# default site een blanco site (op ip)
	server.document-root = "/srv/www"

	ssl.engine = "enable"
        ssl.privkey = "/etc/ssl/private/key-mirror.pem"
        ssl.pemfile = "/etc/ssl/certs/cert-mirror.pem"

	ssl.dh-file = "/etc/lighttpd/dh2048.pem"
	ssl.ec-curve = "prime256v1"

        ssl.cipher-list = "ECDHE-RSA-AES256-SHA384:AES256-SHA256:!RC4:HIGH:!MD5:!aNULL:!EDH:!AESGCM"
        ssl.openssl.ssl-conf-cmd = ("MinProtocol" => "TLSv1.2",
                            "Options" => "ServerPreference,SessionTicket", #(lighttpd 1.4.55 and earlier)
                            "CipherString" => "HIGH")

	# sites mirror.hr.nl en mirror.hro.nl
	$HTTP["host"] =~ "^(aptproxy\.hro?\.nl|debian\.hro?\.nl|mirror\.hro?\.nl|kernel\.hro?\.nl|www\.debian\.hro?\.nl|www\.kernel\.hro?\.nl|www\.mirror\.hro?\.nl|http\.debian\.hro?\.nl|http\.kernel\.hro?\.nl|http\.mirror\.hro?\.nl)$" {

		server.document-root = "/srv/ftp"
		accesslog.filename = "/var/log/lighttpd/mirror.hr.nl-access.log"
		dir-listing.set-footer = "<b>mirror.hr.nl</b> hosted by <a href='https://www.rotterdamuas.com/' style='border-style: none;'><img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAYCAYAAAAPtVbGAAACQUlEQVRIib2WQUhTcRzHP1vG5qabsaRShxOzOiwWo0OXwYhOZZh4SKmgiFq38hJBh7IQArEhBdWlomDqQTCU8OBh4ckOahiUrDCdsdzjsTl17rWxdZCtPffUDZzf6+/3/35+3/fj/95TpVIpvlacvwC4AQs7ozDQbg0PvVWpVKimjY1XgTc7ZL5RzceXhgfVrCcoltwAaqCiiBBLGlJ05Q1RmzWYHpyh2uMqGFKST5OuqZaqh7fR1jUAsHLrM8ZzpzE4nACIfb0sdg6Q9EvKA25nXu1xoS4vzQAAzE8eZQAAptY2jBdPFpZk7wkDhx7fyBiF+ke2mmV9Wn1pfhC1WcOB+y2YWttyGmecl9BYq7A871I0Sq6uyXyyH50McsT7ghJTpexwQhSITfwh6ZfQnarfdNqV0WkAyi4fI7m8RtQ/9x+a3Sgt+HMOB7qekfRLqM0aKl1XFAEBdw/xqQi6plpqOu4SnwvJ6rIksW8z6G12WUPs+28AtPaDsuVnS3u0nrpPDvQ2O2JfL/GpiKwuSxL7McdG7b/ZzOHJp4rmae0724jeZichCix2DuTUZUkk34KiQT5KiAKz1+8p3hVZkuiH3CRpaRpqCH0cVqxFxrz8bLmD5A0q1nPuyeqXCdleYrM+hFfvWXo5SdTpY095GQaHk4QosDw+Tqh/ZMvhFCHp5SdEAeGdB7FjNFOTvEHmvd1A95am20L+BoIE3D2EXo9t+i4qVDmQ7Ml3Srv2Pfm1G5D2okOs4aFB4BrrvzFF0T8R273MWh/oegAAAABJRU5ErkJggg==' alt='HR' style='vertical-align: middle; border-style: none;' /></a> <a href='https://www.hogeschoolrotterdam.nl/' style='color: #787878; font-weight: bold;'>Hogeschool Rotterdam</a> / <a href='https://www.rotterdamuas.com/' style='color: #787878; font-weight: bold;'>Rotterdam University of Applied Sciences</a><img src='https://piwik.hro.nl/piwik.php?idsite=2&rec=1' style='border:0' alt='' />"
		url.rewrite-once = ("^/favicon.ico$" => "/hro/favicon.ico")

		$HTTP["remoteip"] == "145.24.0.0/16" {
			alias.url += ( "/hrdeb" => "/srv/hrdeb/" )
			$HTTP["host"] == "aptproxy.hro.nl" {
				proxy.server = ( "" => ( ( "host" => "127.0.0.1", "port" => "3142" ) ) )
			}
		}

		$HTTP["remoteip"] == "145.51.0.0/16" {
			alias.url += ( "/hrdeb" => "/srv/hrdeb/" )
			$HTTP["host"] == "aptproxy.hro.nl" {
				proxy.server = ( "" => ( ( "host" => "127.0.0.1", "port" => "3142" ) ) )
			}
		}

		# Toegang voor tasarov
		$HTTP["remoteip"] == "46.19.32.138" {
			alias.url += ( "/hrdeb" => "/srv/hrdeb/" )
			$HTTP["host"] == "aptproxy.hro.nl" {
				proxy.server = ( "" => ( ( "host" => "127.0.0.1", "port" => "3142" ) ) )
			}
		}
	}

}
