Pasos para hacer un Upload de 100 Megabytes bajo Nginx y ASP.NET Core 2
(y que no nos salga el error "413 Payload Too Large" (Kestrel) o "413 Request Entity Too Large" (Nginx) )
Paso 1: Modificar nuestro web.config
<configuration>
<system.web>
<httpRuntime maxRequestLength="102400" /><!-- 100 MB in kilobytes -->
</system.web>
<system.webServer>
...
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="102428800" /> <!--100 MB in bytes -->
</requestFiltering>
</security>
...
</system.webServer>
Paso 2: Modificar nuestra configuración de Nginx
En mi caso tengo una configuración propia en /etc/nginx/sites-enabled/proyecto.conf
pero también es factible modificar /etc/nginx/nginx.conf
Añadiendo
client_max_body_size 100M; #si lo establecemos a 0 no hay límite.dentro de la sección location / {} ,y server {..}, aunque también he leído que haría falta en http {...} de nginx.conf
En mi caso yo lo he establecido en location y en server, y me ha funcionado.
Acordarse de luego hacer un nginx -s reload o service nginx reload
Paso 3: Modificar el comportamiento Kestrel
Este paso no aparece en todos los sitios y es esencial.
Nos vamos a Program.cs
.UseKestrel(options=>
{
options.Limits.MaxRequestBodySize = 102428800; //100 Megas en bytes
})
No hay comentarios:
Publicar un comentario