1

Here scenario is , we have app service needs to access the azure container apps hosted as internal, that can be accessesed with the vnet.

The app gateway routing works well if we have one container app and we have achieved using below link- single container solution

if suppose we have 2 container apps , if we have /api1/--> route to container1, if we have /api2/--> route to container2.

we tried to achieve the same but it gives can't able to reach site and the health probe shows success message for both backend pool with 302 cod and as a testing purpose we use http only

Any docx to follow up or expertise on this? if yes can any one suggest best way to test the same

Thomas
  • 24,234
  • 6
  • 81
  • 125
  • you can have a look at url rewrite: https://learn.microsoft.com/en-us/azure/application-gateway/rewrite-url-portal. another approach is to configure multiple listeners with different domain: app1.appgateway.com => app1.containerapp.... you would need to configure DNS record for that (A record) – Thomas Sep 01 '23 at 02:12

1 Answers1

-1

The best way to achieve this is by running those 2 container app as 'internal only' and creating a 3rd container app that is running a proxy of your chosing: e.g: nginx, envoy, caddy, yarp, apache, haproxy etc. and set whatever advanced routing configuration you want there. you can do pretty much whatever nginx or envoy or yarp can do at that moment. Your 'upstream' or 'target' is http://app1 and http://app2 (or whatever you named your apps)

Full example:

Here is an example nginx default.conf that routes /api1 -> app1 and /api2 -> app2

server {
    listen 8080;
    listen [::]:8080;
    server_name _;

    location /api1 {
        proxy_pass http://app1;
        proxy_http_version 1.1;
    }

    location /api2 {
        proxy_pass http://app2;
        proxy_http_version 1.1;
    }
    
    location / {
        return 404;
    }
}

You can either build your own nginx image using

FROM nginx

# assuming the above config is in a file called default.conf
COPY default.conf /etc/nginx/conf.d/

Or use the default nginx image and mount that as a file there. See this bicep template as an example https://github.com/ahmelsayed/bicep-templates/tree/main/apps/routers/nginx

It creates 3 apps, appv1 (internal) and appv2 (internal), and nginx (external), then mounts a very similar nginx config to the one above mapping

  • /version1 -> appv1
  • /version2 -> appv2
  • / -> 404

You can use the same approach with any other proxy

ahmelsayed
  • 7,125
  • 3
  • 28
  • 40
  • Is there any way to make this routing without using separate ngnix conatiner ? – sowndar k Aug 24 '23 at 04:27
  • You can use Application Gateway or Azure Front Door in front of your ACA apps, but currently the only way to achieve this is by the above approach. – ahmelsayed Aug 24 '23 at 18:57