On-premise data gateway DO NOT recognize HOSTS file
That’s it. The title said it all.
I seriously doubt how many SharePoint administrators have even tried to setup on-premise data gateway in their environment. Giving that the gateway have been released for several years, I should not be the only SP admin come across this problem?
The scenario is that, in our testing environment, our SharePoint’s AAM is http://sharepoint.com. Of course we do not owe this domain and we didn’t add this domain name in our company’s DNS. Our developers and testers need to add “sharepoint.com xxx.xxx.xxx.xxx (the WFE ip address)” in their PC’s HOSTS file. Then they are able to browse http://sharepoint.com
However, since on-premise data gateway do not recognize HOSTS file, we cannot configure the gateway correctly. The gateway always throwing 502 bad gateway error. It spent me days to realize that 502 error actually represent the “on-premise data gateway” program cannot connect to SharePoint. Come on! Why don’t you just return “there is not SharePoint in the target URL” error?
To work around our situation, we add the WFE’s ip address into SharePoint’s AAM. In other word, all internal users can browse the site with http://xxx.xxx.xxx.xxx. After AAM setup, the gateway can be configured with this new URL (ip address).