If you found value in this post, consider following me on X @davidpuplava for more valuable information about Game Dev, OrchardCore, C#/.NET and other topics.
If you receive a file exceeds the maximum upload size
in Orchard Core and you're certain the settings allow for the size image you've uploaded, check to see if you have a reverse proxy the is erroring out too big header
response sent from the upstream server.
In my case, the problem was Nginx and not OrchardCore.
In particular, I run Orchard Core in a Kubernetes cluster configured with an Nginx Ingress Controller.
My symptom was that I couldn't upload images larger than 768 KB even though my OrchardCore settings allowed images up to 4 MB.
After solving a different 502 Bad Gateway error when logging into Orchard, I learned that the Nginx Ingress Controller was erroring out because it was running out of buffer space.
From that troubleshooting experience, I learned that I can configure individual Ingresses to increase that buffer size.
The solution was to add these annotations to my ingress for my particular OrchardCore site.
nginx.ingress.kubernetes.io/proxy-body-size: 30m
nginx.ingress.kubernetes.io/proxy-buffer-size: 256k
nginx.ingress.kubernetes.io/proxy-buffering: 'on'
nginx.ingress.kubernetes.io/proxy-buffers-number: '4'
nginx.ingress.kubernetes.io/proxy-max-temp-file-size: 1024m
And that's it!
After I deploy the above ingress annotations to increase the Nginx Ingress controller buffer size, I could sucessfully upload image files up to the size that was configured in OrchardCore media settings.
If you found value in this post, consider following me on X @davidpuplava for more valuable information about Game Dev, OrchardCore, C#/.NET and other topics.