Record credit failures

Another step of #2508. Fixes #1811. Built on top of #2579.
We should test that. If they don't handle `X-Forwarded-For` properly then a client could trivially bypass this check.