Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

path with a dot in web.config <location>

Tags:

I need to add a location element in my web.config file, but the path starts with a dot (and I don't think I can change that path, it's for letsencrypt automation).

If I let the dot, like in <location path=".well-known/acme-challenge"></location>, the site doesn't start at all (I think the web.config file is not parsed at all because I get the page asking me to configure customErrors, but it is already configured and usually works fine)

If I remove the dot, like in <location path="well-known/acme-challenge"></location> the web.config file is correctly loaded, but of course that doesn't help me to configure anything at the location I wish.

The final goal is to disable basic authentication (which I need for the rest of the site) on this path only ; I don't even know if I'll be able to set this up in a <location> element.

like image 311
youen Avatar asked Sep 07 '16 09:09

youen


People also ask

What is location path in Web config?

The path attribute defines the site or virtual directory that the configuration settings cover. To specify that the settings in the <location> element apply to the default Web site, set the path attribute to Default Web Site .

How do I add file path to Web config?

Answers. later you can access the file path using: string filePath = ConfigurationManager. AppSettings["Path"].

Where is the IIS Web config file located?

config files. The configuration files for IIS 7 and later are located in your %WinDir%\System32\Inetsrv\Config folder, and the primary configuration files are: ApplicationHost. config - This configuration file stores the settings for all your Web sites and applications.


2 Answers

I had a similar problem where I had a ASP.NET Forms site that was forcing authentication on all pages.

To expand on the accepted answer, here is the exact web.config I put in the /.well-known folder (NOT the /.well-known/acme-challenge folder):

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <!-- This will stop any redirects you have at the higher level -->
    <httpRedirect enabled="false" />

    <!-- This will stop any integrated mode settings you have at the higher level -->
    <validation validateIntegratedModeConfiguration="false"/>
  </system.webServer>

  <!-- This will allow unauthenticated users to acme-challenge subfolder -->
  <location path="acme-challenge">
    <system.web>
      <authorization>
        <allow users="*"/>
      </authorization>
    </system.web>
  </location>
</configuration>

After adding this file, I was able to use EcdsaAcmeNet to use Lets Encrypt with the site in IIS.

like image 105
Scott R. Frost Avatar answered Sep 28 '22 12:09

Scott R. Frost


As suggested by Ondrej Svedjdar in comments, the solution is so simple I didn't think about it.

Just add another web.config file in the folder where you need it.

like image 45
youen Avatar answered Sep 27 '22 12:09

youen