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
141 # Map api.openstreetmap/0.n/... to api.openstreetmap/api/0.n/...
142 if ($host ~* ^api\.) {
143 rewrite ^/(0\.[0-9]+)/(.*)$ /api/$1/$2;
144 rewrite ^/capabilities$ /api/capabilities;
148 location ~ ^/(images|javascripts|openlayers|stylesheets|user/image)/ {
149 rewrite ^/(.*)/[0-9]+$ /$1;
152 # Include fastcgi configuration
153 include /etc/nginx/fastcgi_params;
154 fastcgi_param REQUEST_URI $uri;
156 # Handle tiles@home requests
158 if ($http_user_agent ~ "^tilesAtHome") {
160 fastcgi_pass tah_backend;
165 # Handle bulk api requests
166 location ~ ^/api/0\.6/(map|relation|trackpoints|amf|amf/read|swf/trackpoints|trace/[0-9]+/data)$ {
167 fastcgi_read_timeout 300;
168 fastcgi_pass bulkapi_backend;
172 # Send search requests to the bulk api backend
173 location ~ ^/api/0\.6/.*/search$ {
174 fastcgi_read_timeout 300;
175 fastcgi_pass bulkapi_backend;
179 # Send requests for full objects to the bulk api backend
180 location ~ ^/api/0\.6/.*/full$ {
181 fastcgi_read_timeout 300;
182 fastcgi_pass bulkapi_backend;
186 # Handle the remaining api requests
187 location ~ ^/api/0\.6/ {
188 fastcgi_pass api_backend;
192 # Deny old and unknown API versions
193 location ~ ^/api/0\.[0-9]+/ {
197 # Handle Special Case Expiry
198 location ~ ^/openlayers/ {
201 location ~ ^/export/embed.html$ {
204 location ~ ^/(images|javascripts|stylesheets)/ {
208 # Send everything else to the web backend unless it exists
209 # in the rails public tree
211 fastcgi_index index.html;
213 if (!-f $request_filename) {
214 fastcgi_pass web_backend;
219 location = /api/capabilities {
220 fastcgi_pass web_backend;
224 # Set the MIME type for crossdomain.xml policy files
225 # or flash will ignore it
226 location ~ /crossdomain\.xml$ {
228 text/x-cross-domain-policy xml;