Fix REMOTE_ADDR for cached subrequests

Fixes #7091