Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache reverse proxy wraps JSON response in HTML

Apologies in advance if this question has been asked before (couldn't find anything quite like it), or is just painstakingly obvious and I'm just a moron for asking.

I'm using Apache 2.4 to reverse proxy a couple of internal pages and web apps. I've got quite a few of the proxy modules enabled, including mod_proxy_html to rewrite the HTML as needed. The each page or web app that is proxied is within blocks.

Generally this works well. Links work, resources load as they should blah, blah, blah. BUT a few of these web apps use AJAX for some nice UX features, most of these AJAX requests hit the proxied 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 coming from, and everything I have tried to get rid of them hasn't worked. I've tried LocationMatch blocks and explicitly setting ProxyHTMLEnable Off and removing substitute output filters that as well.

Is there a way to explicitly disable response body rewriting/substitutions for a particular URL?

like image 654
Nathan Dabkowski Avatar asked Jun 03 '26 11:06

Nathan Dabkowski


1 Answers

I had the same problem. After two days of test i found a solution.

In the Location area you need to comment

#SetOutputFilter  proxy-html

I have just the following lines

< Location /blabla >
    #ProxyHTMLEnable off
    ProxyPassReverse /
    #SetOutputFilter  proxy-html
    ProxyHTMLURLMap  /externalBlaBla/  /blabla/
    ProxyPassReverseCookiePath / /blabla
< /Location >
like image 185
nutria Avatar answered Jun 06 '26 05:06

nutria