Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Internal Server Error with web.config ipSecurity

This is my web.config which has some tags for blocking Ipaddress

<configuration>
 <connectionStrings>
    ...
 </connectionStrings>
 <appSettings>
  ....
 </appSettings> 
 <runtime>
   ....
 </runtime>
  <system.webServer>
    <security> 
        <ipSecurity allowUnlisted="false"> 
            <clear/> 
             <add ipAddress="127.0.0.1" allowed="true"/>
             <add ipAddress="83.116.19.53" allowed="true"/> 
        </ipSecurity>  
    </security>
</system.webServer> 
</configuration>

My intention is to block any other IP except the above. The above is the only Ip address I want the website to be accessible from . But with "ipSecurity" tag I am always getting 500 - Internal server error and the site runs fine without it.

I have made sure that "IP and Domains Restrictions" are installed on the server. Please let me know if I am missing anything. Thank you.

like image 472
Sruthi Avatar asked Apr 25 '13 17:04

Sruthi


4 Answers

For others that run into this issue. The cause of the issue is that Feature Delegation doesn't allow the feature to be managed by web.config.

To Fix:

Verify that the Feature is enabled for web.config management

  • In IIS 7, click on the root server
  • Double click Feature Delegation (under management)
  • Scroll down to IPv4 Address and Domain Restrictions
    • Change the delegation to Read/Write (in my case it was Read Only, which was the issue)

Hope this helps someone else.

like image 170
Summit Avatar answered Nov 10 '22 08:11

Summit


For Windows 10 and Visual Studio 2015 note that the ApplicationHost.config file has been relocated to the .vs\config folder in your project's folder hierarchy. You will need to edit the project specific version of the ApplicationHost.config file found there with...

<section name="ipSecurity" overrideModeDefault="Allow" />

If you only edit the ApplicationHost.config located in your Documents\IISExpress folder this will not affect your existing application (MVC5 appl in my case).

like image 38
Greg Terrell Avatar answered Nov 10 '22 09:11

Greg Terrell


Open the applicationHost.config file (located at %windir%\system32\inetsrv\config\applicationHost.config) and edit the ipSecurity section.

Change this line:

<section name="ipSecurity" overrideModeDefault="Deny" />

To:

<section name="ipSecurity" overrideModeDefault="Allow" />
like image 11
Carlos Silva Avatar answered Nov 10 '22 08:11

Carlos Silva


Are you editing the config by hand or through IIS manager?

See this post about that error message as you may not have that feature delegation enabled

http://forums.asp.net/t/1220987.aspx

like image 7
Brock Hensley Avatar answered Nov 10 '22 08:11

Brock Hensley