set proxy using $http_host in nginx

More reliable regarding the port number when there's a redirect.
on ping, don't treat HTTP 502 bad gateway as failure

Give it time to resolve.