Azure 实例容器:容器连接问题

Azure Instance Container : container connectivity issues

我目前正在尝试在 Azure 容器实例上创建一个新容器,以使用 Nginx Image 在其上部署一个 angular 应用程序前端。

我已经在 Azure 上创建了一个 Container Registry 并在其上推送了一个图像(从本地 Docker)。

此应用程序与后端通信。在本地,我配置 web.config 来设置后端服务器,我 运行 容器;工作了

在 azure 中,当我创建容器时,我的应用程序没有连接到后端(我创建了一个到后端的端口)

这是前端应用中 web.config 的配置:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="ToBack" stopProcessing="true">
          <match url="rc/(.*)" />
          <action type="Rewrite" url="http://X.Y.W.Z:6555/api/{R:1}" logRewrittenUrl="true" />
          <conditions>
          </conditions>
        </rule>
        <rule name="AngularIndex" stopProcessing="true">
          <match url=".*" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="./index.html" />
        </rule>
      </rules>
    </rewrite>
    <httpErrors errorMode="Detailed" />
  </system.webServer>
  <location path="index.html">
    <system.webServer>
      <staticContent>
        <clientCache cacheControlMode="DisableCache" />
      </staticContent>
    </system.webServer>
  </location>

</configuration>

和Docker文件:

FROM nginx:stable-alpine

EXPOSE 80

COPY nginx.conf /etc/nginx/nginx.conf

WORKDIR /usr/share/nginx/html

COPY dist/ .

当我从 ACI 控制台录制 curl http://X.Y.W.Z:6555 时,我从后端得到响应。

有解决办法吗?

T 允许 ACI 中的容器 运行 从您的网络访问其他资源,您需要使用私有 vnet/subnet 配置容器。这将允许您的容器通过私有 IP 访问您的后端实例,而不是尝试进行一些端口转发攻击..

参考:

https://docs.microsoft.com/en-us/azure/container-instances/container-instances-overview#virtual-network-deployment

https://docs.microsoft.com/en-us/azure/container-instances/container-instances-vnet

忘记了Nginx的配置是自己的

现在开始工作

感谢大家