You are correct, azure uses a load balancer proxy for all websites. I don’t believe there is a way to increase the header size at this time. Also your users may be going thru proxies that also limit the request sizes.
Azure App Services Linux - NetCore 3 with Kestrel - Modifying max headers size
Hi, I am running a NetCore 3.0 application in Azure App Services with Linux using Kestrel and I have the need to increase the maximum header size. I am configuring it through code and it works in my local environment, for some reason it's not working when deployed in App Services. Note that I am not using Azure App Gateway or any other service in between so I'm not expecting any restriction on that. The code I'm using is like this, this allows me to send headers up to 500kb size in my local environment:
webBuilder.UseStartup<Startup>().UseKestrel(options =>
{
options.Limits.MaxRequestHeadersTotalSize = 1024 * 500;
options.Limits.MaxRequestBufferSize = 1024 * 1024 * 50;
});
When the app is deployed to App Services the max header size I can pass is around 62kb otherwise I receive a 431 Request Headers Fields Too Large status code. I am wondering if there is any reverse proxy or any other element that could be intercepting the request before reaching my application and limiting that value. Is there anything else I need to configure so the request can reach my app?. Also at the moment I can't figure out how to find where the request is getting blocked, is there any way I could find out more about this? These kind of requests do not reach my app so I'm not able to log anything, I don't know if there is any log I could check in App Services or related to Kestrel where this requests may be logged.
Windows development | Internet Information Services
Developer technologies | ASP.NET | ASP.NET Core
Azure App Service
2 answers
Sort by: Most helpful
-
Bruce (SqlWork.com) 81,356 Reputation points Volunteer Moderator
2023-04-15T17:09:28.25+00:00 -
SnehaAgrawal-MSFT 22,721 Reputation points Moderator
2023-04-25T08:01:33.7366667+00:00 @Manuel Martinez It sounds like you're having trouble increasing the maximum header size for your NetCore 3.0 application running in Azure App Services with Linux using Kestrel. To elaborate:
The “Front Ends” that act as load balancers to the application(s) running behind them have a hard upper limit of 64KB for total request header sizes. The Front End configuration is not able to be changed. This means that although the application side can be changed (as discussed below), and depending on the server running the application - may have a various default total header size limit, but in all cases, the upper limit will always only be 64KB in size.
With .NET Core and Kestrel you can increase header sizes through the
MaxRequestHeadersTotalSizeproperty. This property has a default set to ~32KB for total header sizes. If header size limits are hit, you’ll also encounter anHTTP 431 Request Header Fields Too Largeerror. We can increase the allowed header size with something like the following with Kestrel:builder.WebHost.UseKestrel(k => { // Increase the Request limit size to 64KB k.Limits.MaxRequestHeadersTotalSize = 64000; });You can check requests by enabling logging for your application and check the logs. To enable logging for your application, you can use the Azure App Service Log Stream feature. Let us know if further query.