Post this it works:
https://github.com/discourse/discourse/commit/a988cd5abeaeff94463027f02dded5aa3ee9f372
However we need to change our storage schema for S3 optimized images (and all optimised images) to allow us to send avatar templates down to the client to avoid the redirection.