Use reverse proxy in Azure Container Apps Environment

Fabian Kaimer 5 Reputation points
2023-03-01T23:03:22.4666667+00:00

I'm currently trying to set up a multi-container application in Azure Container Apps with the GUI being a containerized single-page application and the API being a containerized Node back-end. I would like to have one central public endpoint to bundle all inbound and outbound traffic (for logging purposes, to use a custom domain name, etc). I have therefore created a containerized nginx server and configured it as a reverse proxy to proxy_pass all incoming requests to the FQDN of the GUI (for requests coming in on "/" URI). I also added a static index file (under "/public") just for testing purposes.

My nginx.conf:

nginx3

The nginx is deployed to its own container and also serves the static index file as intended. However, it does not redirect any request to the GUI. I either get HTTP "502 - Bad Gateway" or "HTTP 426 - Upgrade Required" (when using http instead of https). I have tried all possible combinations (http/https/no protocol, ports 80/443/no port, ingress set to internal, ingress set to external) but nothing has worked.

My Ingress configuration for the GUI:

ingress1

Every help would be very appreciated since I've been struggling with this issue for a few days now and have no more ideas where it might be coming from.

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

1 answer

Sort by: Most helpful
  1. Fabian Kaimer 5 Reputation points
    2023-03-31T14:15:34.7133333+00:00

    Microsoft could resolve my issue after getting in contact with their support. It wasn't actually a problem with container apps but rather with nginx (which I use for reverse-proxying).

    I had to add the line proxy_ssl_server_name on; to my nginx.conf , thus enabling to use the FQDN with https:// and not getting any protocal errors:

    events{}
    http {
    
        include "/etc/nginx/mime.types";      
    
        server {
    
    	large_client_header_buffers 4 32k;
    
            listen 80;
           
            location /public {    
                root /usr/share/nginx/html/;
                autoindex on;
            }  
    
            location / {
                proxy_pass https://[PUT FQDN HERE];
                proxy_ssl_server_name on;
                proxy_http_version 1.1;
            }  
        }
    }
    
    
    1 person found this answer helpful.