nginx reverse proxy not passing requests

You are passing the initial request Host header sub.example.com to example.com :

proxy_set_header Host $http_host;

When proxying the request, it's likely falling in sub.example.com vhost or default vhost, not example.com vhost, depending on your setup.

Remove this line.