skip to Main Content

I’ve been getting this error using Apache as a reversed proxy for my Apache Tomcat server, whenever I try to download a corrupted PDF the response of the server is empty and I get this on the Apache logs:

AH01328: Line too long, URI /uri/moreruri/docNum, referer: https://example.com/uri/moreruri/docNum

I’ve tried to get the same error on my local server (again with Apache and Apache Tomcat) and it is not happening.

Any ideas why this could be happening? Thanks in advance.

2

Answers


  1. Chosen as BEST ANSWER

    This error was happening because of this line in the /conf/httpd.conf configuration file:

    AddOutputFilterByType SUBSTITUTE application/pdf
    

    Here what Apache tries to do is, whenever a GET is done and that GET is returning a PDF file, it tries to read the file and substitute specific strings of text.

    Those substitutions are defined at this line:

    Substitute "s|http://localhost:8081|https://example.com|in"
    

    When apache receives the GET and sees that we're requesting a PDF file, it tries to read it and substitute those strings, however as the file is corrupt, apache cannot read it.

    It then throws all the PDF content into a single line inside the body of the response, which happens to be (at our specific case), bigger than the default maximum line length (measured in MB).

    This causes the response to be cut, and what we got finally was an empty response.

    We also had this line:

    SubstituteMaxLineLength 5M
    

    It changes the default maximum line length, however our file weighted 20MB and here we're setting the maximum length to 5MB, thus not covering for this specific case.

    Our solution to the problem was to simply remove the first line, as we didn't need to change PDF's contents:

    AddOutputFilterByType SUBSTITUTE application/pdf
    

    You may want, however to change the maximum length using this line:

    SubstituteMaxLineLength LENGTH
    

    I would not advise to do that though because the limit is lower by default for security reasons.


  2. If use Appache server, add this to .httaccess file:

    <IfModule mod_substitute.c>
    SubstituteMaxLineLength 10M
    </IfModule>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search