Azure VM returns 下的 Docker 中的 IIS ARR 反向代理 运行 404
IIS ARR Reverse proxy running in Docker under Azure VM returns 404
我使用 Azure Server Core 2019 VM 设置了许多 docker 个容器,其中 ISS/ARR 3.0 作为反向代理。
当我访问主机时url: "http://[hostname]/deploy" i expect the RP to redirect to http://[docker ip]:81
81 是运行 "deploy" 的独立内部 docker 容器的公开端口。仅供参考:这映射到主机端口 1322...通过外部浏览器访问 hostname:1322 工作正常。
(我也尝试过使用 [hostname]:1322 和 [docker ip]:1322 的重写规则)
无论我做什么,我总是收到 404(未找到)
我不明白为什么。 Azure 本身有什么东西把它搞砸了吗? windows 中 docker 唯一可用的网络是 NAT(通过 docker 网络 ls)。我通过 "docker inspect [container]" 获得了目标 docker 容器的正确 IP 地址,但我认为这是暴露给主机的 IP 地址,其他容器无法看到 运行在主机上。
我如何知道其他 运行 docker 容器可用于 ARR 规则的内部 docker IP 是什么(或者是否有另一种设置方式它动态地知道规则?)
我的 ARR web.config 是:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="deploy" stopProcessing="true">
<match url="^(.*)/deploy" />
<action type="Rewrite" url="http://172.23.60.148:81" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
我的反向代理 docker 文件是:
FROM mcr.microsoft.com/windows/servercore/iis
# Download and install the required URL rewrite and Application Request Routing modules. Clean up after!
ADD http://go.microsoft.com/fwlink/?LinkID=615137 /install/rewrite_amd64.msi
ADD http://go.microsoft.com/fwlink/?LinkID=615136 /install/ARRv3_setup_amd64_en-us.msi
RUN msiexec.exe /i C:\install\rewrite_amd64.msi /qn /log C:\ms_install.log & \
msiexec.exe /i C:\install\ARRv3_setup_amd64_en-us.msi /qn /log C:\arr_install.log & \
rd /s /q c:\install
# Enable proxy feature for IIS. Allows us to act as a reverse proxy
RUN .\Windows\System32\inetsrv\appcmd.exe set CONFIG -section:system.webServer/proxy /enabled:"True" /commit:apphost
# The web config should contain our routing to other containers
ADD ./web.config /inetpub/wwwroot/web.config
所以,原来问题根本不是docker而是ARR。
当您添加重写规则时,逻辑上期望此“^(.*)/deploy”成为匹配条件,即 "ending with /deploy"。 IIS 中的重写规则测试器在您尝试时甚至可以正常工作。
事实证明,IIS 不会将 / 传递给重写规则引擎。它只传递文本 "deploy"... 所以规则永远不会匹配,然后将它传递到基础 IIS 站点而不是目标......当然 /deploy 在基础站点中不存在,因此 404.
这里有相关的 ARR 问题
- Url Rewrite in IIS get 404
我使用 Azure Server Core 2019 VM 设置了许多 docker 个容器,其中 ISS/ARR 3.0 作为反向代理。
当我访问主机时url: "http://[hostname]/deploy" i expect the RP to redirect to http://[docker ip]:81
81 是运行 "deploy" 的独立内部 docker 容器的公开端口。仅供参考:这映射到主机端口 1322...通过外部浏览器访问 hostname:1322 工作正常。
(我也尝试过使用 [hostname]:1322 和 [docker ip]:1322 的重写规则)
无论我做什么,我总是收到 404(未找到)
我不明白为什么。 Azure 本身有什么东西把它搞砸了吗? windows 中 docker 唯一可用的网络是 NAT(通过 docker 网络 ls)。我通过 "docker inspect [container]" 获得了目标 docker 容器的正确 IP 地址,但我认为这是暴露给主机的 IP 地址,其他容器无法看到 运行在主机上。
我如何知道其他 运行 docker 容器可用于 ARR 规则的内部 docker IP 是什么(或者是否有另一种设置方式它动态地知道规则?)
我的 ARR web.config 是:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="deploy" stopProcessing="true">
<match url="^(.*)/deploy" />
<action type="Rewrite" url="http://172.23.60.148:81" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
我的反向代理 docker 文件是:
FROM mcr.microsoft.com/windows/servercore/iis
# Download and install the required URL rewrite and Application Request Routing modules. Clean up after!
ADD http://go.microsoft.com/fwlink/?LinkID=615137 /install/rewrite_amd64.msi
ADD http://go.microsoft.com/fwlink/?LinkID=615136 /install/ARRv3_setup_amd64_en-us.msi
RUN msiexec.exe /i C:\install\rewrite_amd64.msi /qn /log C:\ms_install.log & \
msiexec.exe /i C:\install\ARRv3_setup_amd64_en-us.msi /qn /log C:\arr_install.log & \
rd /s /q c:\install
# Enable proxy feature for IIS. Allows us to act as a reverse proxy
RUN .\Windows\System32\inetsrv\appcmd.exe set CONFIG -section:system.webServer/proxy /enabled:"True" /commit:apphost
# The web config should contain our routing to other containers
ADD ./web.config /inetpub/wwwroot/web.config
所以,原来问题根本不是docker而是ARR。
当您添加重写规则时,逻辑上期望此“^(.*)/deploy”成为匹配条件,即 "ending with /deploy"。 IIS 中的重写规则测试器在您尝试时甚至可以正常工作。
事实证明,IIS 不会将 / 传递给重写规则引擎。它只传递文本 "deploy"... 所以规则永远不会匹配,然后将它传递到基础 IIS 站点而不是目标......当然 /deploy 在基础站点中不存在,因此 404.
这里有相关的 ARR 问题
- Url Rewrite in IIS get 404