Tomcat on Azure gives 502 Bad Gateway error if a file is over 48Kb

Dafydd Owen 96 Reputation points
2021-03-30T16:42:25.857+00:00

I have an old Java/JSP app deployed to an Azure App service.
Config:

  • Stack: Java
  • Java Version : 8 (auto update)
  • Java Web server : Tomcat 7

I'm not a Java/Tomcat developer and had a bit of a struggle migrating it to Azure.
Anyway - found a strange issue.
I realised that the page/browser wasn't loading the jquery file.
In Web browser dev-tools Console It was giving a 502.3 Bad Gateway error - or if I load the file direct it gives the generic "The specified CGI application encountered an error and the server terminated the process."

After a bit of trial and error I realised that it was a file size issue.
I've create multiple text files and they show the same issue.
48Kb - the text file is served by the web server no issue.
49Kb - even just one character more than the ok file - and the 502.3 / CGI error is given.

I can't imagine it's anything to do with the application itself as they're just text files.
So can only guess it's something to do with Azure / Tomcat - and am far from experienced on either.

I've tried getting detailed logs etc - and not getting very far - just saying it's a 502 error.

In the detailed error page downloaded from: \Log Files\DetailedErrors
Module httpPlatformHandler
Notification ExecuteRequestHandler
Handler httpPlatformHandlerMain
Error Code 0x80072f78
Requested URL http://<Azure app name>:80/test/test2.txt
Physical Path C:\home\site\wwwroot\test\test2.txt

In other logs giving:

Fields: date time s-sitename cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Cookie) cs(Referer) cs-host sc-status sc-substatus sc-win32-status sc-bytes cs-bytes time-taken

2021-03-30 14:41:33 <AZURE APP NAME> GET /test/test3.txt X-ARR-LOG-ID=3396835b-8169-4031-8fb9-1f453bab65bd 80 - 80.229.217.19 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/89.0.4389.90+Safari/537.36 _ga=GA1.2.425743202.1478094549;+__utma=64269055.1697910558.1478128282.1603098244.1603100052.3017;+_gid=GA1.2.964745619.1617005796;+ARRAffinity=92ca53ad8db4fbb93d4d3b7d8ab54dcf8ffecb2d731f25b0e91ad575d7534c3f;+JSESSIONID=0F7607CB41252690D499895443A5D633 - <Azure custom URL> 502 3 12152 589 1301 17296
2021-03-30 14:41:33 <AZURE APP NAME> GET /test/test2.txt X-ARR-LOG-ID=54a45472-e683-45f1-9b6d-388c3a0d5fba 80 - 80.229.217.19 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/89.0.4389.90+Safari/537.36 _ga=GA1.2.425743202.1478094549;+__utma=64269055.1697910558.1478128282.1603098244.1603100052.3017;+_gid=GA1.2.964745619.1617005796;+ARRAffinity=92ca53ad8db4fbb93d4d3b7d8ab54dcf8ffecb2d731f25b0e91ad575d7534c3f;+JSESSIONID=0F7607CB41252690D499895443A5D633 - <Azure custom URL>d 502 3 12152 589 1275 7859

I have tried 3 text files:
test1.txt : Just under the limit : Ok
test2.txt : 1 character more : 502.3 error
test3.txt : similar file size to 2 - but only carriage returns : 502.3 error

Azure App Services
Azure App Services
A feature of Azure App Service used to create and deploy scalable, mission-critical web apps.
4,326 questions
{count} votes

Accepted answer
  1. Dafydd Owen 96 Reputation points
    2021-03-31T08:29:47.307+00:00

    I updated it to Tomcat 9 (Auto update) and that seemed to work!


0 additional answers

Sort by: Most helpful