gpt4 book ai didi

iis - 将静态内容重写到 IIS 中的不同域

转载 作者:行者123 更新时间:2023-12-04 21:32:18 25 4
gpt4 key购买 nike

我在 ASP.NET 上有一个本地网站。而且我需要将一些静态内容(从文件夹“静态”)代理到另一个网站。

我添加了这条规则:

<rule name="All in static folder" stopProcessing="true">
<match url="^static/.*" />
<action type="Rewrite" url="http://otherwebsite.com/{R:0}" appendQueryString="true" logRewrittenUrl="true" />
</rule>

但这不起作用 - 基于失败的请求日志,我的路由匹配(PATTERN_MATCH 步骤匹配“true”,然后我在 REWRITE_ACTION 和 RULE_EVALUATION_END 中看到正确的 url)但我看到 ASP.NET 在此之后继续评估其他模块等等试图自己提供内容,点击静态文件处理程序并获得 404(因为磁盘上没有这样的文件)。

我确实可以访问重写的文件(像 http://otherwebSite.com/static/stylesheet.css 这样的文件在浏览器中打开没有任何问题)。还写了一些其他别名(在 etc/hosts 中)并打开 http://otherwebSiteLocalAlias.com/static/stylesheet.css也有效(意味着该网站没有一些主机/代理验证机制)。

将操作更改为“ 重定向 ”也可以,但在我的情况下这是 Not Acceptable 。

我有另一条规则可以代理 非静态资源 (文件夹 url,如/mypage/)到同一主机,它可以工作。它只是不适用于静态文件 - 似乎在 url 重写完成后它的工作正常,请求继续由 asp.net 处理,这不应该是这种情况。

最佳答案

为应用程序请求路由安装 ARR 3.0 和“启用代理”以允许 <action type="Rewrite" .. />重写到不同的域。

enter image description here

以下是如何安装 ARR 3.0 并使用巧克力和 powershell 启用代理。

# download chocolatey
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
choco feature enable -n allowGlobalConfirmation

# install web platform installer cli
choco install webpicommandline -y

#install ARR 3.0
WebpiCmd /Install /Products:"ARRv3_0" /AcceptEULA

# enable proxy on root IIS web server
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.webServer/proxy" -name "enabled" -value "True"

关于iis - 将静态内容重写到 IIS 中的不同域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28426722/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com