title: My Apache reverse proxy adds code to body of fetched HTML files from head tag
body: <p>I have a simple reverse proxy server using Apache 2.4.20 which gets HTML files from an internal Apache web server. The page fetching and URL rewriting is working fine, but there is a problem occurring.</p>
  
  <p>After any webpage is passed through the proxy, three things are incorrect:  the contents of the head tag appears in the body, the head tag is missing and a mysterious ">" character in a "p" tag is added at the top of the body tag.</p>
  
  <p>This extra <code>&lt;p&gt;&gt;&lt;/p&gt;</code> code suggests to me something wrong with the detection of a HTML tag (it could be part of <code>&lt;head&gt;</code>). Also, even without content in the head tag, the body tag still begins with that weird code.</p>
  
  <p><strong>Proxied content - viewed in developer tools, Google Chrome browser:</strong><br>
  <a href="https://i.stack.imgur.com/UbxD8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UbxD8.png" alt="Screenshot image described on above line. http://i.stack.imgur.com/UbxD8.png"></a></p>
  
  <p><strong>Proxied content - original source of fetched file:</strong><br>
  <a href="https://i.stack.imgur.com/nRs4R.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nRs4R.png" alt="Screenshot image described on above line. http://i.stack.imgur.com/nRs4R.png"></a></p>
  
  <p><strong>Original HTML file - opened directly from internal server filesystem:</strong><br>
  <a href="https://i.stack.imgur.com/alxtr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/alxtr.png" alt="Screenshot image described on above line. http://i.stack.imgur.com/alxtr.png"></a></p>
  
  <p><strong>Proxy server configuration file - section about transfer and <code>ProxyHTML</code>:</strong><br>
  <a href="https://i.stack.imgur.com/79t6b.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/79t6b.png" alt="Screenshot image described on above line. http://i.stack.imgur.com/79t6b.png"></a></p>
  
  <p>I know the original server is working correctly so this isn't causing the problem.<br>
  Here's a screenshot of the HTML file viewed directly from the original server in a browser (on the proxy server device), along with source code shown in Chrome Developer Tools:<br>
  <a href="https://i.stack.imgur.com/y81UM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y81UM.png" alt="Screenshot image described in previous sentence. http://i.stack.imgur.com/y81UM.png"></a></p>
  
  <p><em>Update</em>: As expected, <em>mod_proxy_html</em> is the main cause of my problem (turning it off left the original file). However, this <em>isn't a solution</em> for me because I need the tool to rewrite relative URL references in the proxied documents. I read the <a href="https://httpd.apache.org/docs/2.4/mod/mod_proxy_html.html" rel="nofollow noreferrer" title="Apache 2.4 documentation for mod_proxy_html">documentation page</a> but it didn't describe any features that undoubtedly caused my problem.</p>
  
  <p>List of <em>mod_proxy_html</em> directives from the <a href="https://httpd.apache.org/docs/2.4/mod/mod_proxy_html.html" rel="nofollow noreferrer" title="Apache 2.4 documentation for mod_proxy_html">documentation</a> which I think aren't relevant, some tested: <em>ProxyHTMLBufSize</em>, <em>ProxyHTMLCharsetOut</em>, <em>ProxyHTMLDocType</em>, <em>ProxyHTMLEnable</em>, <em>ProxyHTMLEvents</em>, <em>ProxyHTMLExtended</em> (default off), <em>ProxyHTMLFixups</em> (tried from suggestion), <em>ProxyHTMLInterp</em>, <em>ProxyHTMLLinks</em>, <em>ProxyHTMLMeta</em> (default off), <em>ProxyHTMLStripComments</em>, <em>ProxyHTMLURLMap</em>.</p>