Sounds like you need to have your middleware return the user to the front-end (Varnish Server) with an appropriate redirect header, be aware of how Varnish handles redirect codes from it's backends.