1

I'm using Apache proxy to access a web application on a VM.

The proxy configuration works great, no issues.

However, a side effect I see is that the Apache proxy "fixes" HTML that is being proxied.

This isn't a problem for my own material, but it causes awful rendering a third party frame work I'm using, PatternFly.

A simple example of a typical change in the HTML is:

199,200c182,183
<             <td style="vertical-align:middle" rowspan=1><a href="/timesheet/project/9">HWSUPP</td>
<             <td style="vertical-align:middle" rowspan=1><a href="Chris, Welch: chris.welch">Chris Welch</td>
---
>             <td style="vertical-align:middle" rowspan="1"><a href="/timesheet/project/9">HWSUPP</a></td>
>             <td style="vertical-align:middle" rowspan="1"><a href="Chris, Welch: chris.welch">Chris Welch</a></td>

The < HTML is the proxied source, the > is the original.

As you can see, the unnecessary quotes around the rowspan and the terminating tag are removed by the Apache Proxy.

For the most part, these fix ups are helpful, but they are causing rendering problems when I use PatternFly that make the site unusable.

I know, the immediate answer is going to be "fix the bad source", but this isn't practical with thousands of third party source lines and Django templates are generating their own source as well.

Is there anyway to turn off this behaviour with Apache proxy?

The proxy configuration I'm using is (Apache 2.2.15):

ProxyRequests off

ProxyHTMLLogVerbose On
LogLevel Debug

ProxyPass /testcrm/ http://django/
ProxyHTMLURLMap http://django /testcrm

<Location /testcrm/>
        ProxyPassReverse /
        SetOutputFilter  proxy-html
        ProxyHTMLURLMap  /      /testcrm/
        RequestHeader    unset  Accept-Encoding
</Location>

I've tried a test using Apache 2.4 and get the same results.

I came across this, but the question regarding disabling the feature was not answered: mod_proxy(_html) and a buggy Webserver (delivers text/html for JSON data)

  • Although I wasn't able to find a way to turn off the modifications, I found that most of the rendering issues were due to the proxy server removing the doctype. I added: ProxyHTMLDocType '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">' to the configuration and I now get the same rendering as the non proxy view. – Chris Welch Jul 12 at 20:41
  • Try without ProxyPassReverse. Or better remove SetOutputFilter. From its documentation at httpd.apache.org/docs/2.4/mod/mod_proxy_html.html: "This module provides an output filter to rewrite HTML links in a proxy situation, to ensure that links work for users outside the proxy. It serves the same purpose as Apache's ProxyPassReverse directive does for HTTP headers, and is an essential component of a reverse proxy.". You then of course lose completely the feature, no links will be rewritten at all. – Patrick Mevzek Jul 12 at 20:41
  • There is no difference without ProxyPassReverse. I need links to be rewritten to map to difference with the virtual machine usage. Otherwise I'd have to manually change all URLs in the application. – Chris Welch Jul 12 at 20:43
  • Yes ProxyPassReverse deals only with headers, not content, sorry about this false hint. I edited my comment in the meantime, look around SetOutputFilter. – Patrick Mevzek Jul 12 at 20:45
  • That is caused by the SetOutputFilter and ProxyHTMLURLMap directives. The filter has a bunch of options and the documentation is here, but I don't know if any of them will actually help you. apache.webthing.com/mod_proxy_html/config.html – Stephen Ostermiller Jul 13 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.