Not true. For example nginx can use the proxy_pass directive to forward real IP address information and log it
Aside of that, you cannot securely detect this because what it actually does is passing in a header which if not reliably set can be forged.
It's not exactly uncommon that people leak errors, remote code execution is another level though. It doesn't hurt to be careful with such a feature.
It's still only a way to prevent greater damage, you should still not run the debugger enabled in prod.