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 # Include fastcgi configuration
129 include /etc/nginx/fastcgi_params;
131 # Redirect trac requests for historical reasons
133 rewrite ^/trac/(.*)$ http://trac.openstreetmap.org/$1 permanent;
136 # Redirect wiki requests for historical reasons
138 rewrite ^/wiki/(.*)$ http://wiki.openstreetmap.org/$1 permanent;
141 # Placeholder for blocking abuse
144 # Map api.openstreetmap/0.n/... to api.openstreetmap/api/0.n/...
145 if ($host ~* api\.(.*)) {
146 rewrite ^/(0\.[0-9]+)/(.*)$ /api/$1/$2;
150 location ~ ^/(images|javascripts|openlayers|stylesheets)/ {
151 rewrite ^/(.*)/[0-9]+$ /$1;
154 # Handle tiles@home requests
156 if ($http_user_agent ~ "^tilesAtHome") {
158 fastcgi_pass tah_backend;
163 # Handle bulk api requests
164 location ~ ^/api/0\.6/(map|relation|trackpoints|amf|amf/read|swf/trackpoints|trace/[0-9]+/data)$ {
165 fastcgi_pass bulkapi_backend;
169 # Send search requests to the bulk api backend
170 location ~ ^/api/0\.6/.*/search$ {
171 fastcgi_pass bulkapi_backend;
175 # Send requests for full objects to the bulk api backend
176 location ~ ^/api/0\.6/.*/full$ {
177 fastcgi_pass bulkapi_backend;
181 # Handle the remaining api requests
182 location ~ ^/api/0\.6/ {
183 fastcgi_pass api_backend;
187 # Deny old and unknown API versions
188 location ~ ^/api/0\.[0-9]+/ {
192 # Handle Special Case Expiry
193 location ~ ^/openlayers/ {
196 location ~ ^/export/embed.html$ {
199 location ~ ^/(images|javascripts|stylesheets)/ {
203 # Send everything else to the web backend unless it exists
204 # in the rails public tree
206 fastcgi_index index.html;
208 if (!-f $request_filename) {
209 fastcgi_pass web_backend;
214 # Set the MIME type for crossdomain.xml policy files
215 # or flash will ignore it
216 location ~ /crossdomain.xml$ {
217 default_type text/x-cross-domain-policy;