]> git.openstreetmap.org Git - rails.git/blob - config/nginx.conf
Remove private data.
[rails.git] / config / nginx.conf
1 user www-data www-data;
2 worker_processes  2;
3
4 error_log  /var/log/nginx/error.log;
5 pid        /var/run/nginx.pid;
6
7 events {
8         # max clients = worker_processes * worker_connections
9     worker_connections  1024;
10 }
11
12 http {
13     include       /etc/nginx/mime.types;
14     default_type  application/octet-stream;
15
16     #access_log  /var/log/nginx/access.log;
17
18     sendfile        on;
19     #tcp_nopush     on;
20
21     #keepalive_timeout  0;
22     keepalive_timeout  65;
23     tcp_nodelay        on;
24
25     gzip  on;
26         gzip_min_length 1100;
27         gzip_buffers 4 8k;
28         # text/html is added gzip_types by default
29         gzip_types text/plain application/x-javascript application/x-shockwave-flash text/css;
30         
31         #NO CGI SUPPORT IN NGINX fix stat .pl later
32
33         upstream web_backend {
34                 server 127.0.0.1:8000;
35                 server 127.0.0.1:8001;
36                 server 127.0.0.1:8002;
37                 server 127.0.0.1:8003;
38                 server 127.0.0.1:8004;
39                 server 127.0.0.1:8005;
40                 server 127.0.0.1:8006;
41                 server 127.0.0.1:8007;
42                 server 127.0.0.1:8008;
43                 server 127.0.0.1:8009;
44                 server 127.0.0.1:8010;
45                 server 127.0.0.1:8011;
46                 server 127.0.0.1:8012;
47                 server 127.0.0.1:8013;
48                 server 127.0.0.1:8014;
49                 server 127.0.0.1:8015;
50                 server 127.0.0.1:8016;
51                 server 127.0.0.1:8017;
52                 server 127.0.0.1:8018;
53                 server 127.0.0.1:8019;
54                 server 127.0.0.1:8020;
55                 server 127.0.0.1:8021;
56                 server 127.0.0.1:8022;
57                 server 127.0.0.1:8023;
58                 server 127.0.0.1:8024;
59                 server 127.0.0.1:8025;
60                 server 127.0.0.1:8026;
61                 server 127.0.0.1:8027;
62                 server 127.0.0.1:8028;
63                 server 127.0.0.1:8029;
64         }
65
66         upstream api_backend {
67                 server 127.0.0.1:8030;
68                 server 127.0.0.1:8031;
69                 server 127.0.0.1:8032;
70                 server 127.0.0.1:8033;
71                 server 127.0.0.1:8034;
72                 server 127.0.0.1:8035;
73                 server 127.0.0.1:8036;
74                 server 127.0.0.1:8037;
75                 server 127.0.0.1:8038;
76                 server 127.0.0.1:8039;
77                 server 127.0.0.1:8040;
78                 server 127.0.0.1:8041;
79                 server 127.0.0.1:8042;
80                 server 127.0.0.1:8043;
81                 server 127.0.0.1:8044;
82         }
83
84         upstream bulkapi_backend {
85                 server 10.0.0.10:8000;
86                 server 10.0.0.11:8000;
87                 server 10.0.0.12:8000;
88                 server 10.0.0.10:8001;
89                 server 10.0.0.11:8001;
90                 server 10.0.0.12:8001;
91                 server 10.0.0.10:8002;
92                 server 10.0.0.11:8002;
93                 server 10.0.0.12:8002;
94                 server 10.0.0.10:8003;
95                 server 10.0.0.11:8003;
96                 server 10.0.0.12:8003;
97         }
98         
99         upstream tah_backend {
100                 server 10.0.0.10:8004;
101                 server 10.0.0.11:8004;
102                 server 10.0.0.12:8004;
103                 server 10.0.0.10:8005;
104                 server 10.0.0.11:8005;
105                 server 10.0.0.12:8005;
106         }
107
108 server {
109                 listen   80;
110                 server_name  .openstreetmap.org api.openstreetmap.org;
111                 root /home/rails/public;
112                 index index.html;
113                 access_log  /var/log/nginx/openstreetmap.org.access.log;
114         
115                 include /etc/nginx/fastcgi_params;
116
117                 #Redirect Historical Links to correct servers
118                 location /trac/ {
119                         rewrite ^/trac/(.*)$ http://trac.openstreetmap.org/$1 permanent;
120                 }
121
122                 location /wiki/ {
123                         rewrite ^/wiki/(.*)$ http://wiki.openstreetmap.org/$1 permanent;
124                 }
125
126                 location / {
127                         allow all; 
128                 }
129         
130                 #Handle api.openstreetmap/ -> api.openstreetmap/api/
131                 if ($host ~* api\.(.*)) {
132                         rewrite ^/(0\.[0-9]+)/(.*)$ /api/$1/$2
133                 }
134         
135                 location /api/ {
136                         include /etc/nginx/fastcgi_params;
137                         if ($http_user_agent ~ "^tilesAtHome") {
138                                 #deny all;
139                                 fastcgi_pass tah_backend;
140                                 break;
141                         }
142                 }
143
144                 location ~ ^/api/0\.6/(map|relation|trackpoints|amf|amf/read|swf/trackpoints|trace/[0-9]+/data)$ {
145                         fastcgi_pass bulkapi_backend;
146                         break;
147                 }
148                 
149                 location ~ ^/api/0\.6/.*/search$ {
150                         fastcgi_pass bulkapi_backend;
151                         break;
152                 }
153
154                 location ~ ^/api/0\.6/.*/full$ {
155                         fastcgi_pass bulkapi_backend;
156                         break;
157                 }
158
159                 # fastcgi Web / Data Browser / Relations etc
160                 location ~ ^/api/0\.6/ {
161                         fastcgi_pass api_backend;
162                         break;
163                 }
164
165                 #Deny unknown API version
166                 location ~ ^/api/0\.[0-9]+/ {
167                         deny all;
168                 }
169                         
170                 #Handle Special Case Expiry
171                 location ~ ^/(export|openlayers)/ {
172                         expires 7d;
173                 }
174                 location ~ ^/(images|javascripts|stylesheets)/ {
175                         expires max;
176                 }
177         
178                 location / {
179                         fastcgi_index index.html;
180                         if (!-f $request_filename) {
181                                 fastcgi_pass web_backend;
182                                 break;
183                         }
184                 }
185
186                 location /crossdomain.xml {
187                         default_type text/x-cross-domain-policy;
188                 }
189
190                 #error_page  404  /404.html;
191         # redirect server error pages to the static page /50x.html
192         error_page   500 502 503 504  /50x.html;
193         location = /50x.html {
194                         root   /var/www/nginx-default;
195                 }
196         }
197 }