I am pretty sure I am making the stupidest mistake ever, but I can’t figure out why I get 502 Bad Gateway
error when I run my backend application in Docker when I’m trying to upload a file more than 16Mb in Size.
Dockerfile is pretty straightforward:
FROM golang:1.22.4 AS builder
WORKDIR /build
COPY . .
WORKDIR /build/apps/Myapp/backend
RUN go mod download
ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64
RUN go build -ldflags='-s -w -extldflags "-static"' -o myapp-api .
FROM alpine as certs
RUN apk --no-cache add ca-certificates
FROM scratch
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder ["/build/apps/Myapp/backend/myapp-api", "/build/apps/Myapp/backend/.env.production", "/"]
COPY --from=builder ["/build/apps/Myapp/backend/templates", "/templates"]
EXPOSE 4000
ENTRYPOINT ["/myapp-api"]
CMD ["--mode", "prod"]
My backend is Go + Fiber, and it is configured for big files:
app := fiber.New(fiber.Config{
ErrorHandler: utils.ErrorHandler,
BodyLimit: 520 * 1024 * 1024,
JSONEncoder: json.Marshal,
JSONDecoder: json.Unmarshal,
})
And everything works just fine when I run it locally, without Docker. Once it inside Docker, every attempt to upload a file more than 15MB will throw 502 Bad Gateway
error. Smaller files can be uploaded just fine even when in Docker.
So it seems like some kind of a limitation on Docker side.