Report this

What is the reason for this report?

413 Request Entity Too Large - NGINX

Posted on January 9, 2020

Hey guys, I am trying to upload files larger than 200mb using a netcore app deployed to a kubernetes cluster with a load balancer. When I post to the endpoint the file I get an NGINX error 413 Request Entity Too Large - NGINX. This is weird for me because I didn’t install any nginx to proxy the requests through. I read that netcore apps use Kestrel as the server.

service.yaml

apiVersion: v1
kind: Service
metadata:
  name: myapp-api-service
  annotations:
    nginx.ingress.kubernetes.io/proxy-body-size: "0"
spec:
  type: LoadBalancer
  selector:
    app: myapp
    microService: myapp-api
  ports:
    - protocol: TCP
      port: 80
      targetPort: myapp-api

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp-api
spec:
  selector:
    matchLabels:
      app: myapp
      microService: myapp-api
  replicas: 1
  template:
    metadata:
      labels:
        app: myapp
        microService: myapp-api
    spec:
      containers:
        - name: myapp-api
          image: harbor.test.ro/myapp/myapp-api:latest
          imagePullPolicy: Always
          ports:
            - name: myapp-api
              containerPort: 80
              protocol: TCP
      imagePullSecrets:
        - name: regcred

Dockerfile

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-bionic AS build
WORKDIR /app

# # copy csproj and restore as distinct layers
COPY Myapp.API/Myapp.API/*.csproj ./Myapp.API/
# # COPY utils/*.csproj ./utils/
WORKDIR /app/Myapp.API/
RUN dotnet restore

WORKDIR /app/
COPY Myapp.API/. ./Myapp.API/
# COPY utils/. ./utils/
WORKDIR /app/Myapp.API
RUN dotnet publish -c Release -o out


# test application -- see: dotnet-docker-unit-testing.md
# FROM build AS testrunner
# WORKDIR /app/tests
# COPY tests/. .
# ENTRYPOINT ["dotnet", "test", "--logger:trx"]


FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS runtime
WORKDIR /app
COPY --from=build /app/Myapp.API/out ./
ENTRYPOINT ["dotnet", "Myapp.API.dll"]

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.