Sitecore 8.1:Azure 网站被其访问权限 127.0.0.1 禁止

Sitecore 8.1 : azure website forbidden by its access permissions 127.0.0.1

我们将 sitecore 托管在 Azure 网站上。查看日志文件时,我注意到记录了大量错误:

ManagedPoolThread #11 2015:12:20 19:47:59 ERROR Exception in UrlAgent (url: http://localhost/sitecore/service/keepalive.aspx)
Exception: System.Net.WebException
Message: Unable to connect to the remote server
Source: System
   at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
   at System.Net.WebClient.DownloadData(Uri address)
   at System.Net.WebClient.DownloadData(String address)
   at Sitecore.Web.WebUtil.ExecuteWebPage(String url, NameValueCollection headers)
   at Sitecore.Web.WebUtil.ExecuteWebPage(String url)
   at Sitecore.Tasks.UrlAgent.Run()

Nested Exception

Exception: System.Net.Sockets.SocketException
Message: An attempt was made to access a socket in a way forbidden by its access permissions 127.0.0.1:80
Source: System
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)

我们正在使用 IPSecurity 进行 IP 白名单。起初它可能是这个并将 127.0.0.1 添加到白名单中。但是我仍然收到上述错误。

我在某处读到 azure web 应用程序不支持 localhost 或类似的。

有人遇到过这个问题并有解决方案吗?

更新:

应用了 Marek 提供的解决方案。但是我们看到了新的错误:

Exception: System.Net.WebException

Message: The remote server returned an error: (403) Forbidden.

Source: System

   at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)

   at System.Net.WebClient.DownloadData(Uri address)

   at System.Net.WebClient.DownloadData(String address)

   at Sitecore.Web.WebUtil.ExecuteWebPage(String url, NameValueCollection headers)

   at Sitecore.Web.WebUtil.ExecuteWebPage(String url)

   at Sitecore.Tasks.UrlAgent.Run()

您可以在 web.config 中的 keepalive 任务配置中指定服务器 url:

  <agent type="Sitecore.Tasks.UrlAgent" method="Run" interval="00:15:00">
    <param desc="url">http://YOUR_VALID_HOSTNAME/sitecore/service/keepalive.aspx</param>
    <LogActivity>true</LogActivity>
  </agent>

您可以使用相对 URL 而不是绝对。例如:

<param desc="url">/sitecore/service/keepalive.aspx</param>

如果您在 Azure Web 应用程序中使用 Static/Dynamic IP 限制,请不要忘记将内部 Azure IP 地址添加到 <ipSecurity /> 部分。

<security>
  <ipSecurity allowUnlisted="false">
    <clear/>
    <add ipAddress="0.0.0.0" allowed="true"/>
    ...
  </ipSecurity>
</security>