http(s) protocol mismatch between BLOB static web and AKS web API

7/13/2021

Given a simple solution composed by 1(static web application) + 2(Web API). 1 fetches data from 2 using javascript fetch().Locally everything works.

I then deploy the solution to Azure. 1 is deployed as static web app in a Blob, which by default assign an https endpoint. 2 is deployed as containerised in an AKS cluster with the following dockerfile and yaml:

FROM mcr.microsoft.com/dotnet/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
WORKDIR /src
COPY ["AnApi/AnApi.csproj", "AnApi/"]
RUN dotnet restore "AnApi/AnApi.csproj"
COPY . .
WORKDIR "/src/AnApi"
RUN dotnet build "AnApi.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "AnApi.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "AnApi.dll"]
apiVersion: apps/v1
kind: Deployment
metadata:
  name: sa-be
spec:
  selector:
    matchLabels:
      name: sa-be
  template:
    metadata:
      labels:
        name: sa-be
    spec:
      nodeSelector:
        kubernetes.io/os: linux
      containers:
      - name: sa-be
        image: francotiveron/anapi:latest
        resources:
          limits:
            memory: "64Mi"
            cpu: "250m"
---
apiVersion: v1
kind: Service
metadata:
  name: sa-be-s
spec:
  type: LoadBalancer
  selector:
    name: sa-be
  ports:
  - port: 8080
    targetPort: 80

Problem: the browser (Chrome in this case) complains because a https served site is trying to get data from a http API ('Mixed content... this content must also be served over HTTPS').

I have temporarily fixed the issue releasing the constraint (Chrome can be configured for this), however my questions are:

1) Is it possible to set the endpoint for the Blob static web site as http instead of https? If yes, how? 2) What is the correct procedure to deploy 2 into AKS and make it serving over https instead of http?

-- Franco Tiveron
asp.net-web-api
azure-aks
azure-blob-storage
kubernetes

0 Answers