]> git.openstreetmap.org Git - rails.git/blob - config/lighttpd.conf
b5d87f1cb6d61459a662fc53d3b9fc32411c14ab
[rails.git] / config / lighttpd.conf
1 #
2 # Load the modules that we need
3 #
4 server.modules = ( 
5   "mod_access",
6   "mod_accesslog",
7   "mod_cgi",
8   "mod_compress",
9   "mod_evasive",
10   "mod_expire",
11   "mod_fastcgi",
12   "mod_redirect",
13   "mod_status"
14 )
15
16 #
17 # Basic server configuration
18 #
19 server.username = "www-data"
20 server.groupname = "www-data"
21 server.pid-file = "/var/run/lighttpd.pid"
22
23 #
24 # Setup logging
25 #
26 accesslog.filename = "/var/log/lighttpd/access.log"
27 server.errorlog = "/var/log/lighttpd/error.log"
28
29 #
30 # Allow munin to monitor the server's status
31 #
32 $HTTP["remoteip"] == "127.0.0.1" { status.status-url = "/server-status" }
33
34 #
35 # Fail any attempt to access old versions of the API without
36 # getting rails involved at all
37 #
38 $HTTP["url"] =~ "^/api/0.3/" { url.access-deny = ("") }
39 $HTTP["url"] =~ "^/api/0.4/" { url.access-deny = ("") }
40
41 #
42 # IP blocked at SteveC's request as it was trying to download the
43 # history of every object in the database one at a time
44 #
45 $HTTP["remoteip"] == "143.210.16.160" { url.access-deny = ("") }
46
47 #
48 # Rule to block tilesAtHome when somebody decides to queue vast 
49 # number of tiles for rerendering
50 #
51 #$HTTP["useragent"] == "tilesAtHome" { url.access-deny = ("") }
52
53 #
54 # Limit connections to 20 per IP address
55 #
56 evasive.max-conns-per-ip = 20
57
58 #
59 # Setup MIME type mapping
60 #
61 mimetype.assign = (
62   ".css" => "text/css",
63   ".gif" => "image/gif",
64   ".html" => "text/html",
65   ".js" => "application/x-javascript",
66   ".png" => "image/png",
67   ".swf" => "application/x-shockwave-flash",
68   ".txt" => "text/plain",
69   ".xml" => "text/xml"
70 )
71
72 #
73 # Force special MIME type for crossdomain.xml files
74 #
75 $HTTP["url"] =~ "/crossdomain\.xml$" {
76   mimetype.assign = ( ".xml" => "text/x-cross-domain-policy" )
77 }
78
79 #
80 # Enable compression of appropriate static content
81 #
82 compress.filetype = ( 
83   "application/x-javascript",
84   "application/x-shockwave-flash",
85   "text/css",
86   "text/html",
87   "text/plain"
88 )
89
90 #
91 # Set expiry for static content
92 #
93 expire.url = (
94   "/export/" => "access 7 days",
95   "/images/" => "access 10 years",
96   "/javascripts/" => "access 10 years",
97   "/openlayers/" => "access 7 days",
98   "/stylesheets/" => "access 10 years"
99 )
100
101 #
102 # Cache compressed content
103 #
104 compress.cache-dir = "/var/cache/lighttpd"
105
106 #
107 # Redirect trac and wiki requests to the right places
108 #
109 url.redirect = ( 
110   "^/trac/(.*)$" => "http://trac.openstreetmap.org/$1",
111   "^/wiki/(.*)$" => "http://wiki.openstreetmap.org/$1"
112 )
113
114 #
115 # Run anything with a .pl iextension as a CGI script
116 #
117 cgi.assign = ( ".pl" => "/usr/bin/perl" )
118
119 #
120 # Serve static content from the rails public area ourselves
121 #
122 server.document-root = "/var/www/rails/public"
123
124 #
125 # Send everything else to the appropriate FastCGI server
126 #
127 $HTTP["useragent"] == "tilesAtHome" {
128   server.error-handler-404 = "/dispatch.tah"
129 }
130 else $HTTP["url"] =~ "^/api/0\.5/(map|trackpoints|amf|swf/trackpoints)$" {
131   server.error-handler-404 = "/dispatch.bulkapi"
132 }
133 else $HTTP["url"] =~ "^/api/0\.5/.*/search$" {
134   server.error-handler-404 = "/dispatch.bulkapi"
135 }
136 else $HTTP["url"] =~ "^/api/0\.5/" {
137   server.error-handler-404 = "/dispatch.api"
138 }
139 else $HTTP["url"] =~ "^/api/0\.[0-9]+/" {
140   url.access-deny = ("")
141 }
142 else $HTTP["url"] =~ "^/" {
143   server.error-handler-404 = "/dispatch.web"
144 }
145
146 #
147 # Configure the FastCGI servers
148 #
149 fastcgi.server = ( 
150   ".fcgi" => (
151     ( "host" => "127.0.0.1", "port" => 8000, "check-local" => "disable" ),
152     ( "host" => "127.0.0.1", "port" => 8001, "check-local" => "disable" ),
153     ( "host" => "127.0.0.1", "port" => 8002, "check-local" => "disable" ),
154     ( "host" => "127.0.0.1", "port" => 8003, "check-local" => "disable" ),
155     ( "host" => "127.0.0.1", "port" => 8004, "check-local" => "disable" ),
156     ( "host" => "127.0.0.1", "port" => 8005, "check-local" => "disable" )
157   ),
158   ".api" => (
159     ( "host" => "127.0.0.1", "port" => 8006, "check-local" => "disable" ),
160     ( "host" => "127.0.0.1", "port" => 8007, "check-local" => "disable" ),
161     ( "host" => "127.0.0.1", "port" => 8008, "check-local" => "disable" )
162   )
163 )