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;
69 # Define fastcgi backend for geocoder searches
70 upstream geocoder_backend {
71 server 127.0.0.1:8026;
72 server 127.0.0.1:8027;
73 server 127.0.0.1:8028;
74 server 127.0.0.1:8029;
77 # Define fastcgi backend for api requests
78 upstream api_backend {
79 server 127.0.0.1:8030;
80 server 127.0.0.1:8031;
81 server 127.0.0.1:8032;
82 server 127.0.0.1:8033;
83 server 127.0.0.1:8034;
84 server 127.0.0.1:8035;
85 server 127.0.0.1:8036;
86 server 127.0.0.1:8037;
87 server 127.0.0.1:8038;
88 server 127.0.0.1:8039;
89 server 127.0.0.1:8040;
90 server 127.0.0.1:8041;
91 server 127.0.0.1:8042;
92 server 127.0.0.1:8043;
93 server 127.0.0.1:8044;
96 # Define fastcgi backend for bulk api requests
97 upstream bulkapi_backend {
98 server 10.0.0.10:8000;
99 server 10.0.0.11:8000;
100 server 10.0.0.12:8000;
101 server 10.0.0.10:8001;
102 server 10.0.0.11:8001;
103 server 10.0.0.12:8001;
104 server 10.0.0.10:8002;
105 server 10.0.0.11:8002;
106 server 10.0.0.12:8002;
107 server 10.0.0.10:8003;
108 server 10.0.0.11:8003;
109 server 10.0.0.12:8003;
110 server 10.0.0.10:8004;
111 server 10.0.0.11:8004;
112 server 10.0.0.12:8004;
115 # Define fastcgi backend for tiles@home requests
116 upstream tah_backend {
117 server 10.0.0.10:8005;
118 server 10.0.0.11:8005;
119 server 10.0.0.12:8005;
126 # Serve rails public files
127 root /home/rails/public;
129 # Use index.html as the index page
132 # Redirect trac requests for historical reasons
134 rewrite ^/trac/(.*)$ http://trac.openstreetmap.org/$1 permanent;
137 # Redirect wiki requests for historical reasons
139 rewrite ^/wiki/(.*)$ http://wiki.openstreetmap.org/$1 permanent;
142 # Placeholder for blocking abuse
143 include /etc/nginx/blocked_hosts;
146 # Block some bulk download agents
147 if ($http_user_agent ~* LWP::Simple|downloadosm|BBBike) {
152 if ($http_user_agent ~* msnbot|twiceler) {
156 # Map api.openstreetmap/0.n/... to api.openstreetmap/api/0.n/...
157 if ($host ~* ^api\.) {
158 rewrite ^/(0\.[0-9]+)/(.*)$ /api/$1/$2;
159 rewrite ^/capabilities$ /api/capabilities;
163 location ~ ^/(images|javascripts|openlayers|stylesheets|user/image)/ {
165 rewrite ^/(.*)/[0-9]+$ /$1;
167 # Set expiry to the maximum - the asset tag will change
168 # when there is a new version
171 # Only cache OpenLayers for seven days though
172 if ($uri ~ ^/openlayers/) {
177 # Cache the embedded map page for seven days
178 location ~ ^/export/embed.html$ {
182 # Include fastcgi configuration
183 include /etc/nginx/fastcgi_params;
184 fastcgi_param REQUEST_URI $uri;
186 # Handle tiles@home requests
188 if ($http_user_agent ~ "^tilesAtHome") {
190 fastcgi_pass tah_backend;
195 # Handle bulk api requests
196 location ~ ^/api/0\.6/(map|relation|trackpoints|amf|amf/read|swf/trackpoints|trace/[0-9]+/data)$ {
197 fastcgi_read_timeout 300;
198 fastcgi_pass bulkapi_backend;
202 # Send search requests to the bulk api backend
203 location ~ ^/api/0\.6/.*/search$ {
204 fastcgi_read_timeout 300;
205 fastcgi_pass bulkapi_backend;
209 # Send requests for full objects to the bulk api backend
210 location ~ ^/api/0\.6/.*/full$ {
211 fastcgi_read_timeout 300;
212 fastcgi_pass bulkapi_backend;
216 # Handle the remaining api requests
217 location ~ ^/api/0\.6/ {
218 fastcgi_pass api_backend;
222 # Deny old and unknown API versions
223 location ~ ^/api/0\.[0-9]+/ {
227 # Send unversioned capabilities requests to the api backend
228 location = /api/capabilities {
229 fastcgi_pass api_backend;
233 # Send geocoder searches to the geocoder backend
234 location /geocoder/ {
235 fastcgi_pass geocoder_backend;
239 # Send everything else to the web backend unless it exists
240 # in the rails public tree
242 fastcgi_index index.html;
244 if (!-f $request_filename) {
245 fastcgi_pass web_backend;
250 # Set the MIME type for crossdomain.xml policy files
251 # or flash will ignore it
252 location ~ /crossdomain\.xml$ {
254 text/x-cross-domain-policy xml;
258 # Give munin access to some statistics
259 location /server-status {