adjust upstream error handling

- cast upstream errors to 502 (Bad Gateway), rather than just re-raising.
- 400 errors in remote fetch should be 500
- remote 404 is distinguishable from local 404 (still 404, though)
- unify error page templates