File di configurazione e delega amministrativa in IIS7 Piergiorgio Malusardi IT Pro Evangelist http://blogs.technet.com/pgmalusardi File di configurazione di IIS7 • Il metabase di IIS 6 non è più usato • Sono usati diversi file di configurazione in formato XML • Per l’intero server • Per i diversi siti web e le applicazioni • In ogni istante il contenuto dei file di configurazione riflette la reale configurazione del sistema • I file di configurazione sono gerarchici Gerarchia dei file di configurazione Opzionali machine.config Impostazioni per.NET Framework root web.config Impostazioni per ASP.NET applicationHost.config Impostazioni principali di IIS 7.0 web.config Siti web.config Applicazioni web.config Directory virtuali Gerarchia dei file di configurazione Amministratori Windows applicationHost.config Impostazioni principali di IIS 7 Amministratori di siti Web Sito Web 1 web.config Sito Web 2 web.config App 1 web.config App 2 Amministratori di applicazioni web.config Schema dei file di configurazione di IIS7 • Lo schema definisce i file di configurazione: • • • • Struttura Nomi degli elementi Tipi di dati Valori di default • Risiede nelle directory: • Windows\system32\inetinfo\config\schema • È costituito dai file: IIS_schema.xml ASPNET_schema.xml FX_schema.xml • È estensibile con file XML Gruppi di sezioni <system.webServer> <defaultDocument enabled="true"> <files> <add value="Default.htm" /> <add value="Default.asp" /> <add value="index.htm" /> <add value="index.html" /> <add value="iisstart.htm" /> <add value="default.aspx" /> </files> </defaultDocument> </system.webServer> Sezioni <system.webServer> <defaultDocument enabled="true"> <files> <add value="Default.htm" /> <add value="Default.asp" /> <add value="index.htm" /> <add value="index.html" /> <add value="iisstart.htm" /> <add value="default.aspx" /> </files> </defaultDocument> </system.webServer> Collezioni <system.webServer> <defaultDocument enabled="true"> <files> <add value="Default.htm" /> <add value="Default.asp" /> <add value="index.htm" /> <add value="index.html" /> <add value="iisstart.htm" /> <add value="default.aspx" /> </files> </defaultDocument> </system.webServer> Elementi <system.webServer> <defaultDocument enabled="true"> <files> <add value="Default.htm" /> <add value="Default.asp" /> <add value="index.htm" /> <add value="index.html" /> <add value="iisstart.htm" /> <add value="default.aspx" /> </files> </defaultDocument> </system.webServer> Attributi <system.webServer> <defaultDocument enabled="true" > <files> <add value="Default.htm" /> <add value="Default.asp" /> <add value="index.htm" /> <add value="index.html" /> <add value="iisstart.htm" /> <add value="default.aspx" /> </files> </defaultDocument> </system.webServer> Locazioni <location path="MyWebSite" overrideMode="Allow"> <system.webServer> <defaultDocument enabled="true"> <files> <add value="index.htm" /> <add value="iisstart.htm" /> <add value="default.aspx" /> </files> </defaultDocument> </system.webServer> </location> Blocco delle impostazioni • È possibile concedere ai non amministratori di: • Modificare proprietà di configurazione • Sovrascrivere proprietà di configurazione • overrideMode: definisce lo stato di blocco di una sezione di configurazione Blocco di default delle sezioni • Definito in <configSections> • Usa overrideModeDefault <configSections> ... <section name="defaultDocument" overrideModeDefault="Allow" /> ... </configSections> Blocco della sezione <location> <location path="MySite" overrideMode="Deny"> <system.webServer> <defaultDocument/> </system.webServer> </location> <location path="YourSite" overrideMode="Deny"> <system.webServer> <defaultDocument enabled="true"> <files> <clear/> <add value="default.aspx"/> </files> </defaultDocument> </system.webServer> </location> Blocco granulare • Sblocco di una sezione modifica di ogni sua componente (gestori di siti e applicazioni) • Blocco granulare modifiche solo a specifici elementi o attributi • Possibile restringere il tipo di modifica consentita: add, remove o modify lockAttributes e lockAllAttributesExcept • Specifica gli attributi bloccati <location path="MyWebSite" allowOverride="Allow"> <system.webServer> Bloccato <defaultDocument enabled="true” lockAttributes="enabled"> <files> <add value="index.htm" /> <add value="iisstart.htm" /> </files> </defaultDocument> </system.webServer> </location> lockElements • Specifica gli elementi bloccati <location path="MyWebSite" allowOverride="Allow"> <system.webServer> <defaultDocument enabled="true" lockElements="files"> <files> <add value="index.htm" /> <add value="iisstart.htm" /> </files> </defaultDocument> </system.webServer> </location> Bloccato lockElements: add remove clear • Limita cosa può essere fatto ad un elemento <location path="MyWebSite" allowOverride="Allow"> <system.webServer> <defaultDocument enabled="true“> <files lockElements="add“> <add value="index.htm" /> <add value="iisstart.htm" /> </files> </defaultDocument> </system.webServer> </location> Non si possono aggiungere elementi lockItem • Blocca un singolo elemento <location path="MyWebSite" allowOverride="Allow"> <system.webServer> <defaultDocument enabled="true"> <files> <add value="index.htm" lockItem="true" /> <add value="iisstart.htm" /> </files> </defaultDocument> </system.webServer> </location> Bloccato DEMO: FILE DI CONFIGURAZIONE E DELEGA AMMINISTRATIVA Risorse • Sito ufficiale di IIS: http://www.iis.net • Comprendere la delega di configurazione in IIS7 http://learn.iis.net/page.aspx/156/understanding-iis7configuration-delegation/ • Modifica dei file di configurazione (video in inglese): http://learn.iis.net/page.aspx/373/editing-configuration-files/ © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.