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)/ {
160 rewrite ^/(.*)/[0-9]+$ /$1;
163 # Handle Special Case Expiry
164 if ($uri ~ ^/openlayers/) {
168 # Handle Special Case Expiry
169 location ~ ^/export/embed.html$ {
173 # Include fastcgi configuration
174 include /etc/nginx/fastcgi_params;
175 fastcgi_param REQUEST_URI $uri;
177 # Handle tiles@home requests
179 if ($http_user_agent ~ "^tilesAtHome") {
181 fastcgi_pass tah_backend;
186 # Handle bulk api requests
187 location ~ ^/api/0\.6/(map|relation|trackpoints|amf|amf/read|swf/trackpoints|trace/[0-9]+/data)$ {
188 fastcgi_read_timeout 300;
189 fastcgi_pass bulkapi_backend;
193 # Send search requests to the bulk api backend
194 location ~ ^/api/0\.6/.*/search$ {
195 fastcgi_read_timeout 300;
196 fastcgi_pass bulkapi_backend;
200 # Send requests for full objects to the bulk api backend
201 location ~ ^/api/0\.6/.*/full$ {
202 fastcgi_read_timeout 300;
203 fastcgi_pass bulkapi_backend;
207 # Handle the remaining api requests
208 location ~ ^/api/0\.6/ {
209 fastcgi_pass api_backend;
213 # Deny old and unknown API versions
214 location ~ ^/api/0\.[0-9]+/ {
218 # Send everything else to the web backend unless it exists
219 # in the rails public tree
221 fastcgi_index index.html;
223 if (!-f $request_filename) {
224 fastcgi_pass web_backend;
229 location = /api/capabilities {
230 fastcgi_pass web_backend;
234 # Set the MIME type for crossdomain.xml policy files
235 # or flash will ignore it
236 location ~ /crossdomain\.xml$ {
238 text/x-cross-domain-policy xml;
242 # Give munin access to some statistics
243 location /server-status {