]> git.mxchange.org Git - friendica.git/blob - mods/sample-Lighttpd.config
Merge pull request #1338 from annando/1501-global-contacts
[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 # enable SSL
46 ssl.engine = "enable"
47 ssl.pemfile = "/etc/lighttpd/ssl/wordpress.pem"
48 ssl.ca-file = "/etc/lighttpd/ssl/ca.pem"
49
50 # fix for problem between curl and lighttpd
51 server.reject-expect-100-with-417 = "disable"
52
53 # Send everybody to landing
54 page:
55 $SERVER["socket"] == ":80" {
56
57 $HTTP["scheme"] == "http" {
58     $HTTP["host"] =~ ".*" {
59         # This next redirect doesn't appear to ever execute in
60 Firefox
61         # (sometimes, anyway -- caching issue?), but it does seem
62 to
63         # reliably in Google's Chromium browser. If I change it
64 here
65         # and restart Lighty, Firefox still goes to the URL in
66 the
67         # last 'else' below. Or something.
68 Sometimes.
69         server.document-root = "/var/www"
70         url.redirect = (".*" => "https://example.com")
71     }
72 }
73
74 }
75 else $SERVER["socket"] == ":443" {
76
77 $HTTP["scheme"] == "https" {
78
79     $HTTP["host"] == "wordpress.example.com" {
80         server.document-root = "/var/www/wordpress"
81         ssl.pemfile = "/etc/lighttpd/ssl/wordpress.pem"
82         # include
83 "wpmu-rewrites.conf"
84         url.rewrite-if-not-file = (
85             "^/(.*/)?files/$" => "/index.php",
86              "^/(.*/)?files/(.*)" => "/wp-includes/ms-files.php?file=$2",
87              "^(/wp-admin/.*)" => "$1",
88              "^/([_0-9a-zA-Z-]+/)?(wp-.*)" => "/$2",
89              "^/([_0-9a-zA-Z-]+/)?(.*\.php)" => "/$2",
90              "^/(.*)/?$" => "/index.php/$1"
91         )
92     }
93     else $HTTP["host"] == "friendica.example.com" {
94         server.document-root = "/var/www/friendica"
95         ssl.pemfile = "/etc/lighttpd/ssl/friendica.pem"
96         # Got the following 'Drupal Clean URL'after Mike suggested
97 trying
98         # something along those lines, from
99 http://drupal.org/node/1414950
100         url.rewrite-if-not-file = (
101             "^\/([^\?]*)\?(.*)$" => "/index.php?q=$1&$2",
102             "^\/(.*)$" => "/index.php?q=$1"
103         )
104     }
105     else $HTTP["host"] !~ "(friendica.example.com|wordpress.example.com)" {
106         server.document-root = "/var/www/wordpress"
107         ssl.pemfile = "/etc/lighttpd/ssl/wordpress.pem"
108         url.redirect = (".*" => "https://wordpress.example.com/main/")
109     }
110 }
111
112 }
113
114 index-file.names            = ( "index.php", "index.html",
115                                 "index.htm", "default.htm",
116                                "index.lighttpd.html" )
117
118 url.access-deny             = ( "~", ".inc" )
119
120 static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
121
122 include_shell "/usr/share/lighttpd/use-ipv6.pl"
123
124 dir-listing.encoding        = "utf-8"
125 server.dir-listing          = "disable"
126
127 #compress.cache-dir          =
128 "/var/cache/lighttpd/compress/"
129 #compress.filetype           = ( "application/x-javascript", "text/css",
130 "text/html", "text/p\
131 lain"
132 )
133
134
135 include_shell "/usr/share/lighttpd/create-mime.assign.pl"
136 include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
137
138 ---------------( config ends )-----------------