Apache reverse proxy wraps JSON response to HTML
Sorry in advance if this question has been asked before (couldn't find anything like it), or just painstakingly obvious and I'm just a scammer to ask.
I am using Apache 2.4 to reverse the proxy for a couple of internal pages and web applications. I have enough proxy modules including mod_proxy_html to rewrite the HTML as needed. Every page or web application that is proxied is inside blocks.
This usually works well. The links work, the resources are loaded as they should blah, blah, blah. BUT some of these web apps use AJAX for some nice UX features, most of these AJAX requests end up in the proxy JSON endpoint.
My problem is this: Any proxied JSON response is wrapped in
<html><body><p>{ "Example": "Yes" }</html></body></p>
I don't know where these HTML tags are from, and everything I tried to get rid of them didn't work. I tried LocationMatch blocks and explicitly set ProxyHTMLEnable Off and removed the replacement output filters as well.
Is there a way to explicitly disable response body rewriting / replacements for a specific URL?
source to share
I had the same problem. After two days of testing, I found a solution.
In the location area, you need to comment
#SetOutputFilter proxy-html
I only have the following lines
< Location /blabla >
#ProxyHTMLEnable off
ProxyPassReverse /
#SetOutputFilter proxy-html
ProxyHTMLURLMap /externalBlaBla/ /blabla/
ProxyPassReverseCookiePath / /blabla
< /Location >
source to share
This seems to be the issue discussed at https://bahumbug.wordpress.com/2006/10/12/mod_proxy_html-revisited/ .
With modern software releases (since before mod_proxy_html moved to apache.org in 2011), the recommended fix is ββthe xml2StartParse directive.
Having said that, if ProxyHTMLEnable Off didn't fix it (after server reboot), you also have other scoped issues with your config directives.
PS Why can I "register" here using Google Facebook but not with OpenID? How much are Google and Facebook paying you to blackmail me towards them?
source to share