0
votes

I am currently trying to create a new container on Azure Container Instance, to deploy a angular app frontend on it , using Nginx Image.

I have created a Container Registry on Azure and pushed an image on it (from on-premises Docker).

This application communicate with a backend. In local , i configure the web.config to set the backend server and i run the conrtainer ; It's work

In azure , when i create the container , my app doesn't connect with the backend ( i create a portforward to the backend)

This is the configuration of web.config in frontend apps :

<?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>

and the Dockerfile :

FROM nginx:stable-alpine

EXPOSE 80

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

WORKDIR /usr/share/nginx/html

COPY dist/ .

when i tape curl http://X.Y.W.Z:6555 , from the ACI console , i get the responce from the backend.

any idea to fix that ?

2
where is your backend residing ? in a container in the same ACI cluster ? on Azure as a SaaS ?djsly
What are you referring by "the ACI console" ? so you mean when you exec into the nginx container ? docs.microsoft.com/en-us/cli/azure/…djsly
When configuring port-forward, this will only allow the machine where the port forward were initiated to be able to communicate with the forwarded IP. Where are you running the port-forward command from ? Also, how was your ACI instance deployed ?djsly
Do you run the backend and the frontend in the same container group? Or the backend is another Azure service?Charles Xu

2 Answers

0
votes

T allow your container running in ACI to reach other resources from your network, you will need to configure the container with a private vnet/subnet. This will allow your container to reach out your backend instance over the private IP instead of trying to do some port-forward hacks..

ref:

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

0
votes

I forget the configuration of Nginx it's self

Now it's work

thanks to all