Some more logging changes

+ handle more cases in failed upstream fetch
  - turn 599 (tornado client errors) into 400, 404, not 502
  - turn 4XX in 400, not 500
+ log the proxied IP, not the load-balancer's IP
+ log referer of redirects and errors
+ log user agent of errors
+ log all headers of requests that cause unhandled (500) errors

Not logging, but vaguely related to WTF diagnostics:

+ add the current git commit to template footer