1 # vim:ts=4:sw=4:expandtab
3 # Define a custom log format which includes the upstream latency time plus the
4 # contents of our own measurement data:
6 # 2001:4d88:100e:23:3a60:77ff:feab:d3ea - - [01/Oct/2012:23:03:41 +0200] "GET
7 # /search?q=XCreateWindow HTTP/1.1" 200 upstream 188.111.72.14:28080 response
10 log_format upstream '$remote_addr - - [$time_local] "$request" $status '
11 'upstream [$upstream_addr] [$upstream_response_time]=response request $request_time';
13 proxy_cache_path /var/cache/nginx/cache levels=1:2
15 max_size=500m inactive=15m;
17 proxy_temp_path /var/cache/nginx/tmp;
20 # Keep at least 8 connections to the upstream server(s) open.
23 server localhost:28080;
26 # Set aside 10MB of RAM to store the req/s for each client IP address.
27 # This zone allows an average rate of 1 req/s.
28 limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
29 limit_req_zone $binary_remote_addr zone=legacy:10m rate=1r/s;
33 listen [::]:80 default_server ipv6only=on;
35 root /usr/share/dcs/static;
36 index index.html index.htm;
38 server_name codesearch.debian.net;
40 access_log /var/log/nginx/dcs-static.log combined;
42 # 5s is a reasonably high timeout for connections, but also still low
43 # enough that users might wait that long for a reply.
44 proxy_connect_timeout 5s;
46 # Use Keep-Alive to the upstream backend.
47 proxy_http_version 1.1;
48 proxy_set_header Connection "";
49 proxy_set_header Host $host;
55 location /nginx_status {
63 location = /instantws {
64 limit_req zone=one burst=3 nodelay;
66 proxy_set_header Upgrade $http_upgrade;
67 proxy_set_header Connection "upgrade";
68 proxy_read_timeout 3600s;
69 proxy_send_timeout 3600s;
71 proxy_pass http://dcsweb;
74 # We serve these perfectly cacheable JSON result files directly via nginx.
75 location ~ ^/results/(.*)/(.*\.json)$ {
76 alias /dcs-ssd/query_results/$1/$2;
81 location ~ ^/(perpackage-)?results/ {
82 limit_req zone=one burst=3 nodelay;
83 proxy_pass http://dcsweb;
86 # Server-rendered pages (cached and rate-limited) for legacy clients.
87 location ~ ^/(search|show) {
88 # Limit to 1 req/s on average.
89 limit_req zone=legacy burst=3 nodelay;
91 access_log /var/log/nginx/dcs-upstream.log upstream;
93 proxy_read_timeout 120s;
95 set $cache_key $scheme$host$uri$is_args$args$http_accept_encoding;
97 proxy_cache_key $cache_key;
98 proxy_cache_valid 15m;
100 proxy_pass http://dcsweb;
103 # Everything else must be a static page, so we directly deliver (with
104 # appropriate caching headers).
105 location /research/ {
110 # Cache static files for 24 hours.
113 # First attempt to serve request as file, then
114 # as directory, then fall back to displaying a 404.
115 try_files $uri $uri.html $uri/ /index.html;
118 #error_page 404 /404.html;
120 # redirect server error pages to the static page /50x.html
121 error_page 500 502 503 504 /50x.html;