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
8 # 0.756 request 0.756 t0 19.42ms t1 10.90ms t2 6.45ms t3 10.22ms numfiles 2071
11 log_format upstream '$remote_addr - - [$time_local] "$request" $status '
12 'upstream [$upstream_addr] [$upstream_response_time]=response request $request_time '
13 't0 $upstream_http_dcs_t0 '
14 't1 $upstream_http_dcs_t1 '
15 't2 $upstream_http_dcs_t2 '
16 't3 $upstream_http_dcs_t3 '
17 'numfiles $upstream_http_dcs_numfiles '
18 'numresults $upstream_http_dcs_numresults';
20 proxy_cache_path /var/cache/nginx/cache levels=1:2
22 max_size=500m inactive=15m;
24 proxy_temp_path /var/cache/nginx/tmp;
27 # Keep at least 8 connections to the upstream server(s) open.
30 # The instance running on midna.zekjur.net is fast (SSD), but also
31 # low-bandwidth. It might even be offline entirely, in which case we want
32 # to fall-back to the local version (slower, but working).
33 # NOTE: Specifying an IPv6 address didn’t work here :-/ (nginx 1.2.1)
34 #server dyn.zekjur.net:28080;
36 # Local backup instance.
37 #server localhost:28080 backup;
38 server localhost:28080;
41 # Set aside 10MB of RAM to store the req/s for each client IP address.
42 # This zone allows an average rate of 1 req/s.
43 limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
47 listen [::]:80 default_server ipv6only=on;
49 root /usr/share/dcs/static;
50 index index.html index.htm;
52 server_name codesearch.debian.net;
54 access_log /var/log/nginx/dcs-static.log combined;
56 # 5s is a reasonably high timeout for connections, but also still low
57 # enough that users might wait that long for a reply.
58 proxy_connect_timeout 5s;
60 # Use Keep-Alive to the upstream backend.
61 proxy_http_version 1.1;
62 proxy_set_header Connection "";
63 proxy_set_header Host $host;
64 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
66 set_real_ip_from 79.140.39.219;
67 real_ip_header X-Forwarded-For;
69 location /nginx_status {
78 alias /srv/www/collectd-graphs/;
82 location /collection3/share/ {
83 alias /srv/www/collection3/share/;
86 # Include this file on your nginx.conf to support debian cgi-bin scripts using
88 location /collection3/ {
89 # Disable gzip (it makes scripts feel slower since they have to complete
90 # before getting gzipped)
93 # Set the root to /usr/lib (inside this location this means that we are
94 # giving access to the files under /usr/lib/cgi-bin)
98 fastcgi_pass unix:/var/run/fcgiwrap.socket;
100 # Fastcgi parameters, include the standard ones
101 include /etc/nginx/fastcgi_params;
103 # Adjust non standard parameters (SCRIPT_FILENAME)
104 fastcgi_param SCRIPT_FILENAME /srv/www$fastcgi_script_name;
107 location /research/ {
108 alias /srv/www/research/;
112 # Requests which are directly passed to the dcs-web backend
114 # Limit to 1 req/s on average.
115 limit_req zone=one burst=3 nodelay;
117 access_log /var/log/nginx/dcs-upstream.log upstream;
119 proxy_read_timeout 120s;
121 set $cache_key $scheme$host$uri$is_args$args$http_accept_encoding;
123 proxy_cache_key $cache_key;
124 proxy_cache_valid 15m;
126 proxy_pass http://dcsweb/search;
130 # Limit to 1 req/s on average.
131 limit_req zone=one burst=3 nodelay;
133 access_log /var/log/nginx/dcs-upstream.log upstream;
135 proxy_pass http://dcsweb/show;
138 # Everything else must be a static page, so we directly deliver (with
139 # appropriate caching headers).
141 # Cache static files for 24 hours.
144 # First attempt to serve request as file, then
145 # as directory, then fall back to displaying a 404.
146 try_files $uri $uri.html $uri/ /index.html;
149 #error_page 404 /404.html;
151 # redirect server error pages to the static page /50x.html
152 error_page 500 502 503 504 /50x.html;