This repository has been archived by the owner on Feb 5, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
restorer
committed
Jan 15, 2013
1 parent
3a0a084
commit 3bab1ba
Showing
7 changed files
with
211 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
What is it? | ||
=========== | ||
|
||
Virtual hosts + per-directory config for lighttpd. | ||
|
||
Project goal is to automatically convert .htaccess files into lighttpd config, | ||
but currently .htaccess is **NOT** supported. | ||
|
||
But you can convert .htaccess files into .lighttpd, it's easy | ||
(except "RewriteCond %{REQUEST_FILENAME} !-f" - there is no easy way to convert it). | ||
|
||
**examples** folder contains ready-to-go configuration files for some popular projecs. | ||
|
||
How to install | ||
============== | ||
|
||
- Ensure that mod_rewrite and mod_redirect included into server.modules | ||
- Set server.document-root to "/var/www/default" | ||
- Ensure that ".lighttpd", ".enable-www", and ".aliases" is not readable from browser | ||
- Put enable-sites.pl in /usr/share/lighttpd | ||
- Append include_shell "/usr/share/lighttpd/enable-sites.pl" to the end of lighttpd.conf | ||
|
||
Directory structure | ||
=================== | ||
|
||
|- var | ||
| |- www | ||
| | |- somehost.com | ||
| | | |- .aliases | ||
| | | |- .lighttpd | ||
| | | |- somefile.php | ||
| | | |- sources | ||
| | | | |- .lighttpd | ||
| | | | |- nextfile.php | ||
| | | |- ... | ||
| | |- anotherhost.net | ||
| | | |- .enable-www | ||
| | | |- .lighttpd | ||
| | | |- anotherfile.php | ||
| | | |- ... | ||
|
||
.aliases | ||
======== | ||
|
||
Put domain aliases one per line. | ||
If domain is "somehost.com" and .aliases is: | ||
|
||
``` | ||
www | ||
temp | ||
m | ||
``` | ||
|
||
Than folder will be accessible at somehost.com, www.somehost.com, temp.somehost.com, and m.somehost.com | ||
|
||
.enable-www | ||
=========== | ||
|
||
Empty file. Same as append "www" to .aliases. | ||
If domain is "anotherhost.net" and there is .enable-www in it's folder, | ||
than folder will be accessible at anotherhost.net and www.anotherhost.net | ||
|
||
.lighttpd | ||
========= | ||
|
||
Per-directory configuration file. | ||
Following substitutions available: | ||
|
||
**{root}** - root path of current virtual host folder with trailing slash (for example "/var/www/somehost.com/") | ||
**{dir}** - current directory path with trailing slash (for example "/var/www/somehost.com/sources/") | ||
**{url}** - current directory url with trailing slash (for example "/sources/") | ||
|
||
Example of lighttpd.conf | ||
======================== | ||
|
||
``` | ||
server.modules = ( | ||
"mod_access", | ||
"mod_alias", | ||
"mod_rewrite", # Ensure that mod_rewrite and mod_redirect included into server.modules | ||
"mod_redirect" # Ensure that mod_rewrite and mod_redirect included into server.modules | ||
) | ||
server.document-root = "/var/www/default" # Set server.document-root to "/var/www/default" | ||
server.upload-dirs = ( "/var/cache/lighttpd/uploads" ) | ||
server.errorlog = "/var/log/lighttpd/error.log" | ||
server.pid-file = "/var/run/lighttpd.pid" | ||
server.username = "www-data" | ||
server.groupname = "www-data" | ||
index-file.names = ( | ||
"index.php", | ||
"index.html", | ||
"index.htm", | ||
"default.htm" | ||
) | ||
url.access-deny = ( "~", ".inc" ) | ||
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" ) | ||
include_shell "/usr/share/lighttpd/use-ipv6.pl" | ||
# Ensure that ".lighttpd", ".enable-www", and ".aliases" is not readable from browser | ||
# Easy way - just deny all hidden files | ||
$HTTP["url"] =~ "/\." { | ||
url.access-deny = ( "" ) | ||
} | ||
dir-listing.encoding = "utf-8" | ||
server.dir-listing = "disable" | ||
include_shell "/usr/share/lighttpd/create-mime.assign.pl" | ||
include_shell "/usr/share/lighttpd/include-conf-enabled.pl" | ||
# Append include_shell "/usr/share/lighttpd/enable-sites.pl" to the end of lighttpd.conf | ||
include_shell "/usr/share/lighttpd/enable-sites.pl" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Allow pictures, videos and swf files | ||
|
||
url.rewrite-once += ( "\.(?:css|jpe?g|gif|png|flv|swf)(?:\?.*)?$" => "$0" ) | ||
|
||
# Main Menu Links | ||
|
||
url.rewrite-once += ( "^{url}videos/load/([^/?]*)(?:\?(.*))?$" => "{url}seemore.php?load=$1&$2" ) | ||
url.rewrite-once += ( "^{url}videos/load/([^/?]*)/([^/?]*)(?:\?(.*))?$" => "{url}seemore.php?load=$1&page=$2&$3" ) | ||
|
||
url.rewrite-once += ( "^{url}audios/load/([^/?]*)(?:\?(.*))?$" => "{url}audio.php?load=$1&$2" ) | ||
url.rewrite-once += ( "^{url}audios/load/([^/?]*)/([^/?]*)(?:\?(.*))?$" => "{url}audio.php?load=$1&page=$2&$3" ) | ||
|
||
url.rewrite-once += ( "^{url}audios/album/([^/?]*)/(?:[^/?]*)(?:\?(.*))?$" => "{url}audio.php?album=$1&$2" ) | ||
url.rewrite-once += ( "^{url}audios/album/([^/?]*)/(?:[^/?]*)/([^/?]*)(?:\?(.*))?$" => "{url}audio.php?album=$1&page=$2&$3" ) | ||
|
||
url.rewrite-once += ( "^{url}blogs/load/([^/?]*)(?:\?(.*))?$" => "{url}blogs.php?load=$1&$2" ) | ||
url.rewrite-once += ( "^{url}blogs/load/([^/?]*)/([^/?]*)(?:\?(.*))?$" => "{url}blogs.php?load=$1&page=$2&$3" ) | ||
|
||
url.rewrite-once += ( "^{url}albums/load/([^/?]*)(?:\?(.*))?$" => "{url}albums.php?load=$1&$2" ) | ||
url.rewrite-once += ( "^{url}albums/([^/?]*)/([^/?]*)(?:\?(.*))?$" => "{url}albums.php?load=$1&page=$2&$3" ) | ||
|
||
url.rewrite-once += ( "^{url}people_ajax(?:\?(.*))?" => "{url}people_ajax.php?$1" ) | ||
url.rewrite-once += ( "^{url}people/([^/?]*)/([^/?]*)(?:\?(.*))?" => "{url}people.php?load=$1&page=$2&$3" ) | ||
url.rewrite-once += ( "^{url}people(?:\?(.*))?" => "{url}people.php?$1" ) | ||
url.rewrite-once += ( "^{url}upload-media(?:\?(.*))?" => "{url}upload.php?$1" ) | ||
|
||
url.rewrite-once += ( "^{url}groups(?:\?(.*))?" => "{url}groups.php?$1" ) | ||
url.rewrite-once += ( "^{url}search(?:\?(.*))?" => "{url}search.php?$1" ) | ||
|
||
# Action Links | ||
|
||
url.rewrite-once += ( "^{url}videos/([^/?]*)/(?:[^/?]*)(?:\?(.*))?$" => "{url}play.php?vid=$1&$2" ) | ||
url.rewrite-once += ( "^{url}audio/([^/?]*)/(?:[^/?]*)(?:\?(.*))?$" => "{url}play_audio.php?audio=$1&$2" ) | ||
|
||
url.rewrite-once += ( "^{url}category/([^/?]*)(?:\?(.*))?$" => "{url}category_home.php?cid=$1&$2" ) | ||
url.rewrite-once += ( "^{url}category/([^/?]*)/([^/?]*)(?:\?(.*))?$" => "{url}category_home.php?cid=$1&page=$2&$3" ) | ||
|
||
url.rewrite-once += ( "^{url}subcategory/([^/?]*)/(?:[^/?]*)(?:\?(.*))?$" => "{url}category_home.php?sub=$1&$2" ) | ||
url.rewrite-once += ( "^{url}subcategory/([^/?]*)/(?:[^/?]*)/([^/?]*)(?:\?(.*))?$" => "{url}category_home.php?sub=$1&page=$2&$3" ) | ||
|
||
url.rewrite-once += ( "^{url}genre/([^/?]*)(?:\?(.*))?$" => "{url}genre_home.php?cid=$1&$2" ) | ||
url.rewrite-once += ( "^{url}genre/([^/?]*)/([^/?]*)(?:\?(.*))?$" => "{url}genre_home.php?cid=$1&page=$2&$3" ) | ||
|
||
url.rewrite-once += ( "^{url}view-album/([^/?]*)/(?:[^/?]*)(?:\?(.*))?$" => "{url}album_view.php?album=$1&$2" ) | ||
url.rewrite-once += ( "^{url}view-image/([^/?]*)/(?:[^/?]*)(?:\?(.*))?$" => "{url}album_view.php?image=$1&$2" ) | ||
url.rewrite-once += ( "^{url}read_blog/([^/?]*)/(?:[^/?]*)(?:\?(.*))?$" => "{url}read_blog.php?id=$1&$2" ) | ||
|
||
url.rewrite-once += ( "^{url}blogs/category/([^/?]*)/(?:[^/?]*)(?:\?(.*))?$" => "{url}blogs.php?cat_id=$1&$2" ) | ||
url.rewrite-once += ( "^{url}blogs/category/([^/?]*)/(?:[^/?]*)/([^/?]*)(?:\?(.*))?$" => "{url}blogs.php?cat_id=$1&page=$2&$3" ) | ||
|
||
url.rewrite-once += ( "^{url}members/([^/?]*)(?:\?(.*))?$" => "{url}memberprofile.php?user=$1&$2" ) | ||
|
||
# Redirect directory browsing attempts | ||
|
||
url.rewrite-once += ( "^{url}videos/?(?:\?.*)?$" => "{url}seemore.php" ) | ||
url.rewrite-once += ( "^{url}audios/?(?:\?.*)?$" => "{url}audio.php" ) | ||
url.rewrite-once += ( "^{url}blogs/?(?:\?.*)?$" => "{url}blogs.php" ) | ||
url.redirect += ( "^{url}members/?(?:\?.*)?$" => "{url}people" ) | ||
url.rewrite-once += ( "^{url}albums/?(?:\?.*)?$" => "{url}albums.php" ) | ||
|
||
# Some simple blocks | ||
|
||
url.rewrite-once += ( "^{url}[^?]*\?.*?(?i)(?:<|%3C).*script.*(?:>|%3E)" => "{url}index.php" ) | ||
url.rewrite-once += ( "^{url}[^?]*\?.*?GLOBALS(?:=|\[|%[0-9A-Za-z]{0,2})" => "{url}index.php" ) | ||
url.rewrite-once += ( "^{url}[^?]*\?.*?_REQUEST(?:=|\[|%[0-9A-Za-z]{0,2})" => "{url}index.php" ) | ||
url.rewrite-once += ( "^{url}[^?]*\?.*?SELECT(?:=|\[|%[0-9A-Za-z]{0,2})" => "{url}index.php" ) | ||
url.rewrite-once += ( "^{url}[^?]*\?.*?UNION(?:=|\[|%[0-9A-Za-z]{0,2})" => "{url}index.php" ) | ||
|
||
# Error handlers | ||
|
||
server.error-handler-404 = "/404.php" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
server.dir-listing = "disable" |
2 changes: 2 additions & 0 deletions
2
examples/phpmotion.domain.tld/themes/default/templates/.lighttpd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
url.access-deny += ( ".htm", ".html" ) | ||
server.error-handler-404 = "/404.php" |
File renamed without changes.