IpRestrictionModule - HTTP Error 500.19 - Internal Server Error - asp.net

After trying multiple configuration changes, I cannot seem to get past this error. This is a fresh install of Windows Server 2012R2, with all of the options selected under the ASP.NET/IIS modules and features selected. I'm using Visual Studio 2013, and the target framework is 4.5
I have also executed the following commands:
%windir%\system32\inetsrv\appcmd.exe unlock config -section:system.webServer/handlers
%windir%\system32\inetsrv\appcmd.exe unlock config -section:system.webServer/security/ipSecurity
%windir%\system32\inetsrv\appcmd.exe unlock config -section:system.webServer/modules

Try adding
-commit:apphost
to the command, like this
%windir%\system32\inetsrv\appcmd.exe unlock config section:system.webServer/security/ipSecurity -commit:apphost
so that the unlocking is applied at the topmost (applicationhost.config) level instead of the lower web.config levels

Related

Rsyslog: imfile does not switch to inotify mode

I'm trying to send multiple nginx logs to loggly...
Config file: /etc/rsyslog.d/21-nginx.conf
$ModLoad imfile
#$InputFilePollInterval 10
$InputFileMode inotify
$WorkDirectory /var/spool/rsyslog
$PrivDropToGroup adm
# nginx access file:
$InputFileName /var/log/nginx/*access.log
$InputFileTag nginx-access:
$InputFileStateFile stat-nginx-access
$InputFileSeverity info
$InputFilePersistStateInterval 20000
$InputRunFileMonitor
# other stuff continues......
after restart i get this error in log syslog:
imfile: The to-be-monitored file "/var/log/nginx/*access.log" contains wildcards. This is not supported in polling mode. [v8.16.0 try http://www.rsyslog.com/e/2420 ]
activation of module imfile failed [v8.16.0 try http://www.rsyslog.com/e/-3 ]
did i make something wrong?
Are there other places in your rsyslog configuration where the file mode is changed to pulling or the file poll interval is active? The problem with using this kind of legacy syntax is that all the configuration is loaded globally, so things in other configuration files can interact. You might consider using the new action syntax so that the inotify mode is applied to the specific source. You can see an example of it here http://www.rsyslog.com/doc/v8-stable/configuration/modules/imfile.html

Open files in PHPStorm with Vagrant+Symfony application

I know you can open files from Symfony profiler or exception file links using this in project/app/config.yml :
framework:
ide: "phpstorm://open?file=%%f&line=%%l"
More info: http://developer.happyr.com/open-files-in-phpstorm-from-you-symfony-application
However as I'm using vagrant, the file path of the server doesn't match my host.
I have created a PHP web application server in PHPStorm with the propper path mappings, but still doesn't work.
Any ideas?
Thanks
When running your app in a container or in a virtual machine, you can tell Symfony to map files from the guest to the host by changing their prefix. This map should be specified at the end of the URL template, using & and > as guest-to-host separators:
// /path/to/guest/.../file will be opened
// as /path/to/host/.../file on the host
// as /path/to/host/.../file on the host
'phpstorm://%f:%l&/path/to/guest/>/path/to/host/&/foo/>/bar/&...'
Symfony FrameworkBundle Configuration - IDE
The answer given by Jeffry no longer works unfortunately :(. When In configure that with my paths the profiler throws:
ParameterNotFoundException
You have requested a non-existent parameter "f:".
I have configured the path according to this line in the SF docs: This map should be specified at the end of the URL template, which results in this:
phpstorm://open?url=file://%%f&line=%%l&/path/to/guest/>/path/to/host/
However, it does open PHPStorm, but phpstorm does not open the file, so i'm a bit stuck here now.
This solves the issue with the file not opening in PhpStorm from a Vagrant:
phpstorm://open?file=%%f&line=%%l&/path/to/guest/>/path/to/host/
Source: https://youtrack.jetbrains.com/issue/IDEA-65879

IIS 7 Web Deploy can't handle creating sub folder?

For the past few days I'm trying to deploy my package to IIS 7 but I'm getting nowhere.
Whenever I try to publish the package I receive an error saying that the destination folder doesn't exist - but in fact it WAS created on the remote server but was empty (just the folder structure) :/
I'm building my package with a following command:
msbuild.exe /t:CreateWebPackages /toolsversion:4.0 CRM.msbuild
and trying to deploy it with:
CRM.cmd /M:server /Y
Result is:
C:\...WebService.deploy.cmd /M:crm-web /y
=========================================================
SetParameters from:
"C:...WebService.SetParameters.xml"
You can change IIS Application Name, Physical path, connectionString
or other deploy parameters in the above file.
-------------------------------------------------------
Start executing msdeploy.exe
-------------------------------------------------------
"C:\Program Files\IIS\Microsoft Web Deploy\\msdeploy.exe"
-source:package='C:...WebService.zip' -dest:auto,computerName='crm-w
eb-new',includeAcls='False' -verb:sync -disableLink:AppPoolExtension -disableLin
k:ContentExtension -disableLink:CertificateExtension
-setParamFile:"C:...WebService.SetParameters.xml"
Info: Adding sitemanifest (sitemanifest).
Info: Updating createApp (Kruk CRM Web Service/2.0.65000.65000).
Info: Adding contentPath (Kruk CRM Web Service/2.0.65000.65000).
Info: Adding dirPath (Kruk CRM Web Service/2.0.65000.65000).
Info: Adding child dirPath (Kruk CRM Web Service/2.0.65000.65000\bin).
Info: Adding setAcl (Kruk CRM Web Service/2.0.65000.65000).
Error: (2011-10-27 11:07:59) An error occurred when the request was processed on
the remote computer.
Error: Could not find file '\\?\C:\inetpub\wwwroot\CRM\2.0.65000.65000'.
Error count: 1.
But when i edit the SetParameters.xml file and change
<setParameter name="IIS Web Application Name" value="Web Service/2.0.65000.65000" />
to
<setParameter name="IIS Web Application Name" value="Web Service" />
it works!
So is there some magic trick that I need to do in order to create new dirs under the site ?
Found it! After experimenting with almost all of the available options of msbuild, msdeploy, project settings, IIS etc, I've noticed that msdeploy couldn't create my application under site's application pool because apparently it's identity had not high enough privileges to do so.
What did the trick was changing the identity of the site pool to Local System.

How to replace OpenExeConfiguration in a web context (asp.net mvc 1)

OK so we have something that is currently using OpenExeConfiguration for reading a config file, however this doesn't work when running in the web context.
I've tried a variety of different ways of opening the web.config programmatically but I can't seem to get it to read the correct web.config file. In case it matters I am currently debugging it in VS 2008.
1. config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(System.Web.HttpContext.Current.Request.ApplicationPath);
2. config = ConfigurationManager.OpenMappedExeConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = "web.config" }, ConfigurationUserLevel.None);
3. config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
4. config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(null);
5. System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
It either opens up the wrong config file (either the machine config, or the VS /IDE/Web.config) or complains about the error:
{System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: Failed to map the path '/'. ---> System.InvalidOperationException: Failed to map the path '/'.
Edit -
OK so a combination of
config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
AND running Visual Studio 2008 As Administrator worked. Am hoping we don't run into security/permission issues when we deploy to our web server / client environments!
So in the end I used this code (had to handle whether the web application was running, or if our unit test code was running).
System.Configuration.Configuration config = null;
if (System.Web.HttpContext.Current != null && !System.Web.HttpContext.Current.Request.PhysicalPath.Equals(string.Empty))
config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
else
config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
Also have to be running Visual Studio in Administrator mode - which I found out you can set as a property on your shortcut so you don't need to remember each time in Windows 7 to right click and run as administrator :)

IIS giving 503 errors

I am running a Vista machine with IIS7. I believe (not 100% confident) IIS was working fine for me before I installed PHP from php-5.3.5-nts-Win32-VC9-x86.msi from official PHP website. I went ahead with the default install - did not cutomize anything. After the install, http://localhost gives me 503 Service Unavailable error. I have tried diagnosing using following links but can't find anything wrong. Please help me.
http://mvolo.com/blogs/serverside/archive/2006/10/19/Where-did-my-IIS7-server-go_3F00_-Troubleshooting-_2200_service-unavailable_2200_-errors.aspx
http://www.php.net/manual/en/install.windows.iis7.php
My apppools are running:
C:\Windows\System32\inetsrv>appcmd list apppools
APPPOOL "DefaultAppPool" (MgdVersion:v2.0,MgdMode:Integrated,state:Started)
APPPOOL "Classic .NET AppPool" (MgdVersion:v2.0,MgdMode:Classic,state:Started)
I don't see any errors in either the Application Log or the System Log.
The CGI, ISAPI Extensions, ISAPI Filters are all checked as in http://www.php.net/manual/en/install.windows.iis7.php
also set following values in php.ini
fastcgi.impersonate = 1
fastcgi.logging = 0
cgi.fix_pathinfo=1
cgi.force_redirect = 0
following mapping is set in IIS:
Request path: *.php
Module: FastCgiModule
Executable: C:[Path to PHP installation]\php-cgi.exe
Name: PHP_via_FastCGI
C:\Windows\System32\inetsrv>appcmd list config -section:system.webServer/fastCgi
gives:
<system.webServer>
<fastCgi>
<application fullPath="C:\Program Files\PHP\php-cgi.exe" activityTimeout="60
0" requestTimeout="600" instanceMaxRequests="10000">
<environmentVariables>
<environmentVariable name="PHP_FCGI_MAX_REQUESTS" value="10000" />
<environmentVariable name="PHPRC" value="C:\Program Files\PHP\" />
</environmentVariables>
</application>
</fastCgi>
</system.webServer>
the solution provided here fixed the problem for me partly. It had nothing to do with PHP. I had added a url reservation sometime earlier when trying to experiment and self-host
some WCF services, and removing that url reservation solved the problem:
http://haacked.com/archive/2007/05/21/the-iis-7-team-rocks.aspx
netsh http show urlacl
The result showed that I had reserved http://+:80/ which takes precedence over all other URLs on port 80.
Reserved URL : http://+:80/
User: METAVERSE\Phil
Listen: Yes
Delegate: No
SDDL:
D:(A;;GX;;;S-1-5-21-1527697538-1582451445-1978546337-1000)
The solution was to run this command:
netsh http delete urlacl url=http://+:80/
Which removed the reservation.
My php scripts now run, but http://localhost/iisstart.htm is giving me a blank screen. Need to investigate it further...
The blank screen problem was fixed using this post: http://forums.iis.net/p/1158261/1906535.aspx
Control Panel->Programs and Features->Turn Windows features on/off->IIS->WWW Services->Common Http features->Static Content

Resources