]> git.mxchange.org Git - friendica.git/blob - mods/sample-Lighttpd.config
Add sample lighttpd config, from the mailing list.
[friendica.git] / mods / sample-Lighttpd.config
1 Below is a sample config for Lighttpd that
2 seems to work well on Debian Squeeze, with "lighttpd/1.4.28 (ssl)"
3
4 The idea is: if someone enters the bare URL for my site, 'example.com',
5 they get redirected to https://example.com/index.html, which is simply a
6 page with two links on it: https://wordpress.example.com and
7 https://friendica.example.com.
8
9 If someone enters https://example.com, they get redirected to
10 https://wordpress.example.com/main/, which is the 'main' blog in a Word
11 Press 'network install' of the 'subdirectory' variety.
12
13 I thought it might be nice to offer people who join my Friendica
14 instance their own blogs, if they like.
15
16 One can obtain free, signed, single subdomain SSL certificates from
17 StartCom CA, which upon checking I noticed was already installed in both
18 Firefox and Google Chromium.  Info at http://cert.startcom.org/ .  So I
19 got one for each site, and have Lighty use the appropriate cert based on
20 the requested URL.
21
22 Enjoy!
23
24 ---------------( config starts )-----------------
25
26 debug.log-request-handling = "disable"
27 debug.log-condition-handling = "disable"
28
29 server.modules = (
30         "mod_access",
31         "mod_alias",
32         "mod_compress",
33         "mod_redirect",
34         "mod_fastcgi",
35         "mod_rewrite"
36 )
37
38 server.document-root        = "/var/www"
39 server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
40 server.errorlog             = "/var/log/lighttpd/error.log"
41 server.pid-file             = "/var/run/lighttpd.pid"
42 server.username             = "www-data"
43 server.groupname            = "www-data"
44
45 ssl.engine = "enable"
46 ssl.pemfile = "/etc/lighttpd/ssl/wordpress.pem"
47 ssl.ca-file = "/etc/lighttpd/ssl/ca.pem"
48
49 # Send everybody to landing
50 page:                                                            
51 $SERVER["socket"] == ":80" {
52
53 $HTTP["scheme"] == "http" {
54     $HTTP["host"] =~ ".*" {
55         # This next redirect doesn't appear to ever execute in
56 Firefox                       
57         # (sometimes, anyway -- caching issue?), but it does seem
58 to                         
59         # reliably in Google's Chromium browser. If I change it
60 here                         
61         # and restart Lighty, Firefox still goes to the URL in
62 the                           
63         # last 'else' below. Or something. 
64 Sometimes.                                       
65         server.document-root = "/var/www"
66         url.redirect = (".*" => "https://example.com")
67     }
68 }
69
70 }
71 else $SERVER["socket"] == ":443" {
72
73 $HTTP["scheme"] == "https" {
74
75     $HTTP["host"] == "wordpress.example.com" {
76         server.document-root = "/var/www/wordpress"
77         ssl.pemfile = "/etc/lighttpd/ssl/wordpress.pem"
78         # include
79 "wpmu-rewrites.conf"                                                       
80         url.rewrite-if-not-file = (
81             "^/(.*/)?files/$" => "/index.php",
82              "^/(.*/)?files/(.*)" => "/wp-includes/ms-files.php?file=$2",
83              "^(/wp-admin/.*)" => "$1",
84              "^/([_0-9a-zA-Z-]+/)?(wp-.*)" => "/$2",
85              "^/([_0-9a-zA-Z-]+/)?(.*\.php)" => "/$2",
86              "^/(.*)/?$" => "/index.php/$1"
87         )
88     }
89     else $HTTP["host"] == "friendica.example.com" {
90         server.document-root = "/var/www/friendica"
91         ssl.pemfile = "/etc/lighttpd/ssl/friendica.pem"
92         # Got the following 'Drupal Clean URL'after Mike suggested
93 trying                    
94         # something along those lines, from
95 http://drupal.org/node/1414950                   
96         url.rewrite-if-not-file = (
97             "^\/([^\?]*)\?(.*)$" => "/index.php?q=$1&$2",
98             "^\/(.*)$" => "/index.php?q=$1"
99         )
100     }
101     else $HTTP["host"] !~ "(friendica.example.com|wordpress.example.com)" {
102         server.document-root = "/var/www/wordpress"
103         ssl.pemfile = "/etc/lighttpd/ssl/wordpress.pem"
104         url.redirect = (".*" => "https://wordpress.example.com/main/")
105     }
106 }
107
108 }
109
110 index-file.names            = ( "index.php", "index.html",
111                                 "index.htm", "default.htm",
112                                "index.lighttpd.html" )
113
114 url.access-deny             = ( "~", ".inc" )
115
116 static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
117
118 include_shell "/usr/share/lighttpd/use-ipv6.pl"
119
120 dir-listing.encoding        = "utf-8"
121 server.dir-listing          = "disable"
122
123 #compress.cache-dir          =
124 "/var/cache/lighttpd/compress/"                               
125 #compress.filetype           = ( "application/x-javascript", "text/css",
126 "text/html", "text/p\
127 lain"
128 )                                                                               
129
130
131 include_shell "/usr/share/lighttpd/create-mime.assign.pl"
132 include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
133
134 ---------------( config ends )-----------------