2 user www-data www-data;
4 # Use two worker processes
8 pid /var/run/nginx.pid;
11 error_log /var/log/nginx/error.log;
14 # max clients = worker_processes * worker_connections
15 worker_connections 1024;
19 # Configure MIME types
20 include /etc/nginx/mime.types;
21 default_type application/octet-stream;
23 # Configure network details
29 access_log /var/log/nginx/access.log;
31 # Configure compression (text/html is compressed by default)
35 gzip_types text/plain application/x-javascript application/x-shockwave-flash text/css;
37 #NO CGI SUPPORT IN NGINX fix stat .pl later
39 # Define fastcgi backend for web pages
40 upstream web_backend {
41 server 127.0.0.1:8000;
42 server 127.0.0.1:8001;
43 server 127.0.0.1:8002;
44 server 127.0.0.1:8003;
45 server 127.0.0.1:8004;
46 server 127.0.0.1:8005;
47 server 127.0.0.1:8006;
48 server 127.0.0.1:8007;
49 server 127.0.0.1:8008;
50 server 127.0.0.1:8009;
51 server 127.0.0.1:8010;
52 server 127.0.0.1:8011;
53 server 127.0.0.1:8012;
54 server 127.0.0.1:8013;
55 server 127.0.0.1:8014;
56 server 127.0.0.1:8015;
57 server 127.0.0.1:8016;
58 server 127.0.0.1:8017;
59 server 127.0.0.1:8018;
60 server 127.0.0.1:8019;
61 server 127.0.0.1:8020;
62 server 127.0.0.1:8021;
63 server 127.0.0.1:8022;
64 server 127.0.0.1:8023;
65 server 127.0.0.1:8024;
66 server 127.0.0.1:8025;
67 server 127.0.0.1:8026;
68 server 127.0.0.1:8027;
69 server 127.0.0.1:8028;
70 server 127.0.0.1:8029;
73 # Define fastcgi backend for api requests
74 upstream api_backend {
75 server 127.0.0.1:8030;
76 server 127.0.0.1:8031;
77 server 127.0.0.1:8032;
78 server 127.0.0.1:8033;
79 server 127.0.0.1:8034;
80 server 127.0.0.1:8035;
81 server 127.0.0.1:8036;
82 server 127.0.0.1:8037;
83 server 127.0.0.1:8038;
84 server 127.0.0.1:8039;
85 server 127.0.0.1:8040;
86 server 127.0.0.1:8041;
87 server 127.0.0.1:8042;
88 server 127.0.0.1:8043;
89 server 127.0.0.1:8044;
92 # Define fastcgi backend for bulk api requests
93 upstream bulkapi_backend {
94 server 10.0.0.10:8000;
95 server 10.0.0.11:8000;
96 server 10.0.0.12:8000;
97 server 10.0.0.10:8001;
98 server 10.0.0.11:8001;
99 server 10.0.0.12:8001;
100 server 10.0.0.10:8002;
101 server 10.0.0.11:8002;
102 server 10.0.0.12:8002;
103 server 10.0.0.10:8003;
104 server 10.0.0.11:8003;
105 server 10.0.0.12:8003;
108 # Define fastcgi backend for tiles@home requests
109 upstream tah_backend {
110 server 10.0.0.10:8004;
111 server 10.0.0.11:8004;
112 server 10.0.0.12:8004;
113 server 10.0.0.10:8005;
114 server 10.0.0.11:8005;
115 server 10.0.0.12:8005;
122 # Serve rails public files
123 root /home/rails/public;
125 # Use index.html as the index page
128 # Redirect trac requests for historical reasons
130 rewrite ^/trac/(.*)$ http://trac.openstreetmap.org/$1 permanent;
133 # Redirect wiki requests for historical reasons
135 rewrite ^/wiki/(.*)$ http://wiki.openstreetmap.org/$1 permanent;
138 # Placeholder for blocking abuse
139 include /etc/nginx/blocked_hosts;
142 # Block some bulk download agents
143 if ($http_user_agent ~* LWP::Simple|downloadosm|BBBike) {
148 if ($http_user_agent ~* msnbot|twiceler) {
152 # Map api.openstreetmap/0.n/... to api.openstreetmap/api/0.n/...
153 if ($host ~* ^api\.) {
154 rewrite ^/(0\.[0-9]+)/(.*)$ /api/$1/$2;
155 rewrite ^/capabilities$ /api/capabilities;
159 location ~ ^/(images|javascripts|openlayers|stylesheets|user/image)/ {
161 rewrite ^/(.*)/[0-9]+$ /$1;
163 # Set expiry to the maximum - the asset tag will change
164 # when there is a new version
167 # Only cache OpenLayers for seven days though
168 if ($uri ~ ^/openlayers/) {
173 # Cache the embedded map page for seven days
174 location ~ ^/export/embed.html$ {
178 # Include fastcgi configuration
179 include /etc/nginx/fastcgi_params;
180 fastcgi_param REQUEST_URI $uri;
182 # Handle tiles@home requests
184 if ($http_user_agent ~ "^tilesAtHome") {
186 fastcgi_pass tah_backend;
191 # Handle bulk api requests
192 location ~ ^/api/0\.6/(map|relation|trackpoints|amf|amf/read|swf/trackpoints|trace/[0-9]+/data)$ {
193 fastcgi_read_timeout 300;
194 fastcgi_pass bulkapi_backend;
198 # Send search requests to the bulk api backend
199 location ~ ^/api/0\.6/.*/search$ {
200 fastcgi_read_timeout 300;
201 fastcgi_pass bulkapi_backend;
205 # Send requests for full objects to the bulk api backend
206 location ~ ^/api/0\.6/.*/full$ {
207 fastcgi_read_timeout 300;
208 fastcgi_pass bulkapi_backend;
212 # Handle the remaining api requests
213 location ~ ^/api/0\.6/ {
214 fastcgi_pass api_backend;
218 # Deny old and unknown API versions
219 location ~ ^/api/0\.[0-9]+/ {
223 # Send everything else to the web backend unless it exists
224 # in the rails public tree
226 fastcgi_index index.html;
228 if (!-f $request_filename) {
229 fastcgi_pass web_backend;
234 location = /api/capabilities {
235 fastcgi_pass web_backend;
239 # Set the MIME type for crossdomain.xml policy files
240 # or flash will ignore it
241 location ~ /crossdomain\.xml$ {
243 text/x-cross-domain-policy xml;
247 # Give munin access to some statistics
248 location /server-status {