dcs-package-importer: don’t add a leading / to the index
[debiancodesearch.git] / nginx.example
blobb8ac99a1f2c73f5343f8f55b0251e8f7e757d170
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
9 # numresults 41
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
21     keys_zone=main:50m
22     max_size=500m inactive=15m;
24 proxy_temp_path /var/cache/nginx/tmp;
26 upstream dcsweb {
27     # Keep at least 8 connections to the upstream server(s) open.
28     keepalive 8;
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;
45 server {
46     listen   80;
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 {
70         auth_basic off;
71         stub_status on;
72         access_log off;
73         allow 127.0.0.1;
74         deny all;
75     }
77     location /stats/ {
78         alias /srv/www/collectd-graphs/;
79         autoindex on;
80     }
82     location /collection3/share/ {
83         alias /srv/www/collection3/share/;
84     }
86     # Include this file on your nginx.conf to support debian cgi-bin scripts using
87     # fcgiwrap
88     location /collection3/ { 
89       # Disable gzip (it makes scripts feel slower since they have to complete
90       # before getting gzipped)
91       gzip off;
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)
95       root  /srv/www/;
97       # Fastcgi socket
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;
105     }
107     location /research/ {
108         alias /srv/www/research/;
109         autoindex on;
110     }
112     # Requests which are directly passed to the dcs-web backend
113     location = /search {
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;
122         proxy_cache main;
123         proxy_cache_key $cache_key;
124         proxy_cache_valid 15m;
126         proxy_pass http://dcsweb/search;
127     }
129     location = /show {
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;
136     }
138     # Everything else must be a static page, so we directly deliver (with
139     # appropriate caching headers).
140     location / {
141         # Cache static files for 24 hours.
142         expires 24h;
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;
147     }
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;