I'd use IIS rewrite module. https://docs.microsoft.com/en-us/iis/configuration/system.webserver/httpredirect/
Not tested but you'll end up with something like
<rule name="redirect" enabled="true" stopProcessing="false">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="example.com" />
</conditions>
<action type="Redirect" url="http://127.0.0.1/{R:1}" redirectType="Permanent" />
</rule>