[英]Add proxy element to applicationHost.config in system.webServer section via Powershell
I am trying to add <proxy enabled="true" />
element under system.webServer
section.我正在尝试在
system.webServer
部分下添加<proxy enabled="true" />
元素。
Add-WebConfigurationProperty -Filter '/system.webServer/proxy' -Name . -Value @{ enabled="true" }
Above command does nothing.上面的命令什么都不做。
Add-WebConfigurationProperty -Filter '/system.webServer' -Name 'proxy' -Value @{ enabled="true" }
Above command throws error: Property proxy is not found on system.webServer
上面的命令抛出错误:
Property proxy is not found on system.webServer
Add-WebConfiguration -Filter '/system.webServer/proxy' -Value @{ enabled="true" }
Also does nothing.也什么都不做。
Set-WebConfigurationProperty -Filter '/system.webServer/proxy' -Name 'enabled' -Value 'true'
Shows warning: Target configuration object '/system.webServer/proxy is not found at path 'MACHINE/WEBROOT/APPHOST'.
显示警告:
Target configuration object '/system.webServer/proxy is not found at path 'MACHINE/WEBROOT/APPHOST'.
I find these commands very counterintuitive.我发现这些命令非常违反直觉。 What is the right way to add new element?
添加新元素的正确方法是什么?
EDIT:编辑:
I was testing these commands on Windows 2019 Core with default IIS 10.0我在 Windows 2019 Core 上测试这些命令,默认为 IIS 10.0
I have Windows Server 2012 R2 with IIS 8.5我有 Windows Server 2012 R2 和 IIS 8.5
I can setup proxy on Win2012 with command appcmd set config -section:system.webServer/proxy /enabled:"true" /commit:apphost
, but the same command doesn't work on Win2019.我可以使用命令
appcmd set config -section:system.webServer/proxy /enabled:"true" /commit:apphost
在 Win2012 上设置代理,但相同的命令在 Win2019 上不起作用。 It shows error Unknown config section "system.webServer/proxy".
它显示错误
Unknown config section "system.webServer/proxy".
So, this setting may be not valid for IIS 10.0因此,此设置可能对 IIS 10.0 无效
First you need to make sure ARR has install like Lex Li said.首先,您需要确保 ARR 已像 Lex Li 所说的那样安装。
Then try this powershell command, it can work well in my server 2019.然后尝试这个 powershell 命令,它可以在我的服务器 2019 中正常运行。
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.webServer/proxy" -name "enabled" -value "True"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.