X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/b90e70bd914823701fa1db8dcab52833c230c42b..30176160e6be8e05a9dc5c748cf1def9b077c4e5:/config/nginx.conf diff --git a/config/nginx.conf b/config/nginx.conf index 04a87ebc2..1aa52c5c8 100644 --- a/config/nginx.conf +++ b/config/nginx.conf @@ -1,10 +1,11 @@ -user www-data; -worker_processes 1; +user www-data www-data; +worker_processes 2; error_log /var/log/nginx/error.log; pid /var/run/nginx.pid; events { + # max clients = worker_processes * worker_connections worker_connections 1024; } @@ -26,6 +27,7 @@ http { gzip_buffers 4 8k; # text/html is added gzip_types by default gzip_types text/plain application/x-javascript application/x-shockwave-flash text/css; + #NO CGI SUPPORT IN NGINX fix stat .pl later upstream web_backend { @@ -103,70 +105,109 @@ http { server 10.0.0.12:8005; } - server { - listen 80; - server_name .openstreetmap.org api.openstreetmap.org; - root /home/rails/public - - access_log /var/log/nginx/openstreetmap.org.access.log; - - location / { - deny 143.210.16.160; - allow all; - } +server { + listen 80; + server_name .openstreetmap.org api.openstreetmap.org; + root /home/rails/public; + index index.html; + access_log /var/log/nginx/openstreetmap.org.access.log; + + include /etc/nginx/fastcgi_params; + #Redirect Historical Links to correct servers location /trac/ { rewrite ^/trac/(.*)$ http://trac.openstreetmap.org/$1 permanent; } + location /wiki/ { rewrite ^/wiki/(.*)$ http://wiki.openstreetmap.org/$1 permanent; } - if ($http_user_agent == "tilesAtHome" { + location / { + deny 143.210.16.160; + deny 69.89.21.73; + deny 91.89.145.219; + deny 195.190.169.111; + deny 84.237.213.10; + deny 70.22.219.249; + deny 83.226.40.87; + deny 82.178.145.87; + deny 91.78.50.134; + deny 91.77.7.139; + deny 85.126.23.106; + deny 213.171.196.166; + deny 81.151.8.64; + deny 130.226.235.215; + deny 141.99.254.253; + deny 61.228.43.32; + allow all; + } + + #Handle api.openstreetmap/ -> api.openstreetmap/api/ + if ($host ~* api\.(.*)) { + rewrite ^/(0\.[0-9]+)/(.*)$ /api/$1/$2 + } + + location /api/ { include /etc/nginx/fastcgi_params; - fastcgi_pass tah_backend; - break; + if ($http_user_agent ~ "^tilesAtHome") { + #deny all; + fastcgi_pass tah_backend; + break; + } } - location =~ "^/api/0\.6/(map|trackpoints|amf|amf/read|swf/trackpoints)$" { - include /etc/nginx/fastcgi_params; + location ~ ^/api/0\.6/(map|relation|trackpoints|amf|amf/read|swf/trackpoints|trace/[0-9]+/data)$ { fastcgi_pass bulkapi_backend; break; } - location =~ "^/api/0\.6/.*/search$" { - include /etc/nginx/fastcgi_params; + location ~ ^/api/0\.6/.*/search$ { fastcgi_pass bulkapi_backend; break; } - location =~ "^/api/0\.6/" { - include /etc/nginx/fastcgi_params; + location ~ ^/api/0\.6/.*/full$ { + fastcgi_pass bulkapi_backend; + break; + } + + # fastcgi Web / Data Browser / Relations etc + location ~ ^/api/0\.6/ { fastcgi_pass api_backend; break; } - location =~ "^/api/0\.[0-9]+/" { + #Deny unknown API version + location ~ ^/api/0\.[0-9]+/ { deny all; } - - if (!-f $request_filename) { - include /etc/nginx/fastcgi_params; - fastcgi_pass web_backend; - break; + + #Handle Special Case Expiry + location ~ ^/(export|openlayers)/ { + expires 7d; + } + location ~ ^/(images|javascripts|stylesheets)/ { + expires max; + } + + location / { + fastcgi_index index.html; + if (!-f $request_filename) { + fastcgi_pass web_backend; + break; + } } location /crossdomain.xml { - default_type text/x-cross-domain-policy + default_type text/x-cross-domain-policy; } - #error_page 404 /404.html; + #error_page 404 /404.html; # redirect server error pages to the static page /50x.html error_page 500 502 503 504 /50x.html; location = /50x.html { - root /var/www/nginx-default; - } - + root /var/www/nginx-default; + } } } -