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;
30 limit_req_zone $binary_remote_addr zone=results:10m rate=3r/s;
34 listen [::]:80 default_server ipv6only=on;
36 root /usr/share/dcs/static;
37 index index.html index.htm;
38 server_name codesearch.debian.net;
39 access_log /var/log/nginx/dcs-static.log combined;
41 location '/.well-known/acme-challenge' {
42 default_type "text/plain";
43 root /var/www/letsencrypt-webroot;
47 return 301 https://codesearch.debian.net$request_uri;
53 listen [::]:443 ssl http2 ipv6only=on;
55 ssl_certificate /etc/letsencrypt/live/codesearch.debian.net/fullchain.pem;
56 ssl_certificate_key /etc/letsencrypt/live/codesearch.debian.net/privkey.pem;
58 # See http://cipherli.st/
59 ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
60 ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
61 ssl_prefer_server_ciphers on;
62 ssl_session_cache shared:SSL:10m;
63 ssl_session_tickets off; # Requires nginx >= 1.5.9
64 add_header Strict-Transport-Security "max-age=31536000; includeSubdomains" always;
65 add_header X-Xss-Protection "1; mode=block" always;
66 add_header Content-Security-Policy "default-src: 'self'; script-src 'self' 'unsafe-inline' https://yandex.st" always;
67 # https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options
68 add_header X-Frame-Options DENY;
69 add_header X-Content-Type-Options nosniff;
70 ssl_stapling on; # Requires nginx >= 1.3.7
71 ssl_stapling_verify on; # Requires nginx => 1.3.7
72 resolver 8.8.8.8 8.8.4.4 valid=300s;
74 ssl_ecdh_curve secp384r1; # Requires nginx >= 1.1.0
75 ssl_dhparam /etc/nginx/dhparams.pem;
77 root /usr/share/dcs/static;
78 index index.html index.htm;
80 server_name codesearch.debian.net;
82 access_log /var/log/nginx/dcs-static.log combined;
84 # 5s is a reasonably high timeout for connections, but also still low
85 # enough that users might wait that long for a reply.
86 proxy_connect_timeout 5s;
88 # Use Keep-Alive to the upstream backend.
89 proxy_http_version 1.1;
90 proxy_set_header Connection "";
91 proxy_set_header Host $host;
92 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
97 # An up-to-date list can be found at:
98 # https://github.com/h5bp/server-configs-nginx/blob/master/nginx.conf
99 # Compress all output labeled with one of the following MIME-types.
102 application/javascript
105 application/manifest+json
107 application/vnd.geo+json
108 application/vnd.ms-fontobject
109 application/x-font-ttf
110 application/x-web-app-manifest+json
111 application/xhtml+xml
121 text/vnd.rim.location.xloc
124 text/x-cross-domain-policy;
125 # text/html is always compressed by gzip module
127 location /nginx_status {
135 location = /instantws {
136 limit_req zone=one burst=3 nodelay;
138 proxy_set_header Upgrade $http_upgrade;
139 proxy_set_header Connection "upgrade";
140 proxy_set_header Host $host;
141 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
142 proxy_read_timeout 3600s;
143 proxy_send_timeout 3600s;
145 proxy_pass http://dcsweb;
149 limit_req zone=one burst=3 nodelay;
151 proxy_set_header Host $host;
152 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
153 proxy_read_timeout 3600s;
154 proxy_send_timeout 3600s;
156 proxy_pass http://dcsweb;
160 limit_req zone=results burst=5 nodelay;
162 proxy_pass http://dcsweb;
165 location ~ ^/(perpackage-)?results/ {
166 limit_req zone=results burst=5 nodelay;
168 set $cache_key $scheme$host$uri$is_args$args$http_accept_encoding;
170 proxy_cache_key $cache_key;
171 proxy_cache_valid 1h;
173 proxy_pass http://dcsweb;
176 # Server-rendered pages (cached and rate-limited) for legacy clients.
177 location ~ ^/(search|show) {
178 # Limit to 1 req/s on average.
179 limit_req zone=legacy burst=3 nodelay;
181 access_log /var/log/nginx/dcs-upstream.log upstream;
183 proxy_read_timeout 120s;
185 set $cache_key $scheme$host$uri$is_args$args$http_accept_encoding;
187 proxy_cache_key $cache_key;
188 proxy_cache_valid 15m;
190 proxy_pass http://dcsweb;
193 location /placeholder.html {
194 proxy_pass http://dcsweb;
197 # Everything else must be a static page, so we directly deliver (with
198 # appropriate caching headers).
199 location /research/ {
204 # Cache static files for half a year. We use cache busters (e.g. a ?2
205 # parameter) for every asset that needs updating.
208 # First attempt to serve request as file, then
209 # as directory, then fall back to displaying a 404.
210 try_files $uri $uri.html $uri/ /index.html;
213 #error_page 404 /404.html;
215 # redirect server error pages to the static page /50x.html
216 error_page 500 502 503 504 /50x.html;