Container App to run on both Ingress HTTP and TCP simultaneously

Behzad Hosseini 0 Reputation points
2023-04-29T12:04:00.6866667+00:00

I have a hybrid NestJS app that runs both on HTTP and TCP at the same time. When deploying to Azure Container Apps, I can set Ingress to route traffic for either HTTP or TCP. However, I would need Ingress to intelligently route the traffic based on the request protocol. Is there a way to achieve that?

At the moment, I am running two distinct containers of the same app in my Container App Environment, each with different Ingress type to support my use case.

Azure Container Apps
Azure Container Apps
An Azure service that provides a general-purpose, serverless container platform.
419 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RevelinoB 2,780 Reputation points
    2023-04-29T13:19:56.57+00:00

    Hi Behzad, Yes, you can achieve intelligent routing based on the request protocol by leveraging Azure Application Gateway in combination with Azure Container Apps.

    Azure Application Gateway is a layer 7 load balancer that allows you to route and balance traffic based on various conditions, including request protocol. You can configure the Application Gateway to listen on both HTTP and TCP ports and then route the traffic to the appropriate backend container based on the protocol of the incoming request.

    To accomplish this, you can follow these steps:

    • Deploy an Azure Application Gateway in front of your Azure Container Apps environment.
    • Configure the Application Gateway with multiple listeners, one for HTTP and another for TCP, specifying the appropriate ports for each.
    • Create corresponding backend pools and backend targets for your containers.
    • Define rules and routing logic within the Application Gateway to route traffic based on the request protocol. For example, you can set up a rule that forwards HTTP traffic to the backend pool associated with the HTTP container and TCP traffic to the backend pool associated with the TCP container.
    • Ensure that the appropriate ports are exposed and correctly handled in your containers' configuration.

    By using this these steps, you can have a single hybrid NestJS app running in your Azure Container Apps environment, while Azure Application Gateway intelligently routes the traffic based on the request protocol, eliminating the need for separate containers for HTTP and TCP.

    Please be aware that the specific steps and configurations I described. may vary depending on your Azure setup and requirements

    I hope this helps?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.