简体   繁体   English

Azure 应用程序网关文件上传限制

[英]Azure Application Gateway file upload limits

Recently I'm working with the Azure Application Gateway and when I try to upload a file I got the response 413 Entity Too Large.最近我正在使用 Azure 应用程序网关,当我尝试上传文件时收到响应 413 实体太大。 I read about it and the limit for the file upload is 2GB but I'm very confused because I uploaded successfully a file of 3.2 GB.我读到了它,文件上传的限制是 2GB,但我很困惑,因为我成功上传了一个 3.2GB 的文件。 Are there any change in this limit?.这个限制有什么变化吗? It fails when I try to upload a file of 4.6 GB.当我尝试上传 4.6 GB 的文件时失败。 I'm using Standard_v2 SKU size.我使用的是 Standard_v2 SKU 尺寸。

Other answer is misleading or poorly written.其他答案具有误导性或写得不好。 This answer should make it clearer as there are a few details这个答案应该更清楚,因为有一些细节

Considering you want to enable the maximum limits on the V2 SKU , it behaves like this:考虑到您要启用V2 SKU的最大限制,它的行为如下:

  • No WAF enabled: 4GB (this is 2GB on V1 SKU) - the type of request does not matter, can be a non-upload request.未启用 WAF:4GB(这是 V1 SKU 上的 2GB)- 请求类型无关紧要,可以是非上传请求。
  • Any configuration with WAF enabled without 'Inspect request body': 4GB - the type of request does not matter, can be a non-upload request.启用 WAF 且未启用“检查请求正文”的任何配置:4GB - 请求类型无关紧要,可以是非上传请求。
  • WAF enabled via 'Application Gateway WAF policy' resource (this is a separate resouce) and OWASP 3.2 policy with 'Inspect request body' checked and with value 4000 on 'Max file upload size (MB)': 4GB - but only when your request has the Content-Type set to multipart/form-data , this will recognize it as a file upload (I've tested a bunch of other header values, and so far that one is only recognized as a file upload).通过“应用程序网关 WAF 策略”资源(这是一个单独的资源)和 OWASP 3.2 策略启用了“检查请求正文”并且“最大文件上传大小(MB)”的值为 4000:4GB - 但当您的请求将Content-Type设置为multipart/form-data ,这会将其识别为文件上传(我已经测试了一堆其他 header 值,到目前为止,只有一个被识别为文件上传)。 Any other content type will result in the evaluation of the maximum value set in the 'Max request body size (KB)' field, which can only handle 2000KB (2MB) as maximum value on OWASP 3.2 currently and just 128 KB for lower OWASP versions.任何其他内容类型都将导致评估“最大请求正文大小 (KB)”字段中设置的最大值,目前 OWASP 3.2 只能处理 2000KB (2MB) 作为最大值,对于较低的 OWASP 版本只能处理 128 KB .

If you go over the limit, you get the following message with HTTP status code 403:如果您 go 超过限制,您会收到以下消息,状态代码 HTTP 为 403:

 <html> <head> <title>403 Forbidden</title> </head> <body> <center> <h1>403 Forbidden</h1> </center> <hr> <center>Microsoft-Azure-Application-Gateway/v2</center> </body> </html>

If you have WAF enabled and if your content type is a form based like application/json or application/xml or multipart/form-data , then it is considered as non-file upload.如果您启用了 WAF 并且您的内容类型是基于表单的表单,例如 application/json 或 application/xml 或 multipart/form-data ,则将其视为非文件上传。

OWASP rule is blocking the file upload. OWASP 规则阻止文件上传。 Check here for the rule definition. 在此处查看规则定义。

Work with your application team to change the content type or disable the rule in your WAF is you feel it is not an attach to your application.如果您觉得 WAF 不是应用程序的附件,请与您的应用程序团队合作更改内容类型或禁用 WAF 中的规则。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM