This is the correct solution. Your concern is unnecessary. Cloudflare is passing that IP in a HTTP header.