IIS+服务结构+URLACL
我正在尝试使用可承载的Web核心在服务结构中运行IIS 我认为,问题在于服务结构正在为http://+:12345和http://localhost:12345,但IIS确实需要用于http://*:12345的URLACL。带星号的。弱通配符 因此,我正在寻找一个解决方案,而不仅仅是我自己的设置入口点。不过,这就是我要去的地方 使IIS注册强绑定的方法,或使服务结构分配弱URLACL的方法IIS+服务结构+URLACL,iis,azure-service-fabric,Iis,Azure Service Fabric,我正在尝试使用可承载的Web核心在服务结构中运行IIS 我认为,问题在于服务结构正在为http://+:12345和http://localhost:12345,但IIS确实需要用于http://*:12345的URLACL。带星号的。弱通配符 因此,我正在寻找一个解决方案,而不仅仅是我自己的设置入口点。不过,这就是我要去的地方 使IIS注册强绑定的方法,或使服务结构分配弱URLACL的方法 想法?我不会为可承载的Web核心而烦恼,它已经完全过时了。让IIS在服务结构上运行的方法是在Window
想法?我不会为可承载的Web核心而烦恼,它已经完全过时了。让IIS在服务结构上运行的方法是在Windows容器中运行IIS,并让服务结构管理容器。以下是一个指导您完成此过程的教程:
虽然该教程使用Docker Compose,但它不是必需的;如果您不想处理Docker Compose,可以在ServiceManifest.xml中指定一个容器。如果您只想在服务结构群集上安装完整的IIS或其他任何内容,可以通过在ServiceManifest.xml文件的CodePackage元素中指定安装脚本自动完成 请参见下面的示例:
<CodePackage Name="Code" Version="1.0.0">
<SetupEntryPoint>
<ExeHost>
<Program>Scripts\install.bat</Program>
</ExeHost>
</SetupEntryPoint>
<EntryPoint>
<ExeHost>
<Program>MyService.exe</Program>
<WorkingFolder>CodePackage</WorkingFolder>
</ExeHost>
</EntryPoint>
</CodePackage>
对于install-iis.ps1,内容应为:
@echo off
cd /d "%~dp0"
powershell.exe -ExecutionPolicy Bypass -File ".\install-iis.ps1" -force > install-iis.log
Set-ExecutionPolicy Bypass -Scope Process
# Exit early if IIS is already installed.
$installed = (Get-WindowsOptionalFeature -Online `
| where { $_.state -eq "Enabled" -and $_.FeatureName -eq "IIS-WebServer" } `
| Measure-Object).Count;
if ($installed -gt 0) { return; }
# Install IIS and all relevant features.
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServer -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-CommonHttpFeatures -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpErrors -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpRedirect -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ApplicationDevelopment -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-NetFxExtensibility45 -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HealthAndDiagnostics -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpLogging -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-LoggingLibraries -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-RequestMonitor -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpTracing -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-Security -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-RequestFiltering -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-Performance -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerManagementTools -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-IIS6ManagementCompatibility -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-Metabase -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ManagementConsole -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-BasicAuthentication -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WindowsAuthentication -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-StaticContent -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-DefaultDocument -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebSockets -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ApplicationInit -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ASPNET45 -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ISAPIExtensions -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ISAPIFilter -All
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpCompressionStatic -All
现在,有趣的部分来了——您必须将代码包设置为以管理员身份运行!否则,你就不能做像安装IIS这样有趣的事情我花了一些时间才弄明白并确定,但是,您需要转到服务结构项目解决方案中的.sfproj文件,并找到ApplicationManifest.xml文件
在文件的最后,作为ApplicationManifest元素的最后一个子元素,添加Principals和Policys元素:
好了。现在,当您安装服务时,它将确保计算机上存在IIS
您可以执行其他设置操作,例如在IIS中的其他.ps1文件中设置站点,并在bat文件中为每个文件添加行-确保在内容中设置其他文件,如果更新,请复制 我确实通过使用SetupEntryPoint运行自定义netsh命令来处理绑定,从而解决了这个问题。但我对此不满意,所以问题仍然悬而未决。你能把它作为答案之一吗?可能会有帮助。谢谢,但这不是一个真正的选择。需要加入域的计算机。在这种情况下,您必须在安装入口点脚本中使用netsh,并将ServiceManifest.xml从protocol=http更改为protocol=tcp,这样SF就不会为您创建ACL。知道如何在应用程序重新启动或关闭时清理这些ACL吗?您只需在代码包的SetupEntryPoint中使用powershell脚本安装IIS功能。不过,我对IIS的存在不感兴趣,我对使用ServiceFabric制作URLACL感兴趣。
<Principals>
<Users>
<User Name="SfAdminUser" AccountName="SfAdminUser">
<MemberOf>
<SystemGroup Name="Administrators" />
</MemberOf>
</User>
</Users>
</Principals>
<Policies>
<DefaultRunAsPolicy UserRef="SfAdminUser" />
</Policies>
<ServiceManifestImport>
<ServiceManifestRef ServiceManifestName="MyService.Pkg" ServiceManifestVersion="1.0.0" />
<ConfigOverrides>
[ . . . redacted . . . ]
</ConfigOverrides>
<Policies>
<RunAsPolicy CodePackageRef="Code" UserRef="SfAdminUser" EntryPointType="All" />
</Policies>
</ServiceManifestImport>