Discourse stripping ESI tag when adding custom footer

This is going to be too late, footer is dynamically added so any mangling your varnish wants to do will happen too late.

You are going to have to figure out a different solution here.