Vagif Abilov
Vagif Abilov

Reputation: 9991

Is it possible to set IP restrictions for Windows Azure Web sites?

We are using Windows Azure Web Sites, so we don't create Web roles. Now we need to temporarily set IP restrictions for the site, and I am not sure this is possible for Web Sites.

What is usually done is adding ipSecurity element to system.webServer section in web.config. But the ipSecurity section is locked by default, so it must be first unlocked by running a script command. But running Startup script is not possible for Azure Web sites, is it?

Does this mean that for Azure Web Sites (that don't have Web roles) it's simply not possible to configure IP range restriction?

Upvotes: 1

Views: 1138

Answers (2)

cory-fowler
cory-fowler

Reputation: 4088

Nir Mashkowski explains in a blog post on how you can enable IP Restriction in Windows Azure Web Sites.

Upvotes: 2

Fabrizio Accatino
Fabrizio Accatino

Reputation: 2292

AFAIK ipSecurity is not active on Azure Web Sites.

Workaround: you can write a small piece of code in global.asax Application_BeginRequest and check the client ip address on your allowed IP addresses list. You can load the list on Application_Start.

protected void Application_BeginRequest(...)
{
  string clientIP = request.UserHostAddress;
  if (!Check(clientIP, myOKList))
  {
    Response.Write("<html><body>You are not authorized!</body></html>");
    Response.End();
  }
}

Upvotes: 1

Related Questions