2

We've got a Webserver that answers to AJAX requests by sending JSON Data to the client. Problem is that the JSON Data has the content-type "text/html" instead of "application/json" (it's an Oracle APEX Server, the bug is acknowledged by Oracle but they won't fix it).

Between the clients and the server is an Apache Webserver configured as a SSL-Proxy. That Proxy will now scan every "text/html" Data transmitted from the Server to the client, rewrite links if necessary and, unfortunately, will also fix "malformed" html data. Since the JSON Data sent from the server is labeled as text/html, those html fixes are also applied to the JSON Data (<html><body>.. tags will be added for example), which renders it unusable by the requesting client (parse errors).

What I tried up to now

  • /apex/wwv_flow.show is the function delivering JSON Data. I'd like that to be proxied without any rewriting, while the rest of /apex/ should be proxied "the normal way".
  • I've added "Header set X-Rule-..." just to trace which <Location> Rule is applied.

 <Location "/apex/wwv_flow.show">
    ProxyPass http://192.168.1.100:8080/apex/wwv_flow.show
    Header set "X-Rule-apex-wwv_flow.show" "1"
    Header set Content-Type "application/json"
 </Location>
 <Location /apex/>
    ProxyPass http://192.168.1.100:8080/apex/
    Header set "X-Rule-apex" "1"
    Header always set Cache-Control "no-cache, no-store, max-age=0, must-revalidate" env=nocache
    SetOutputFilter INFLATE;proxy-html;DEFLATE
    ProxyPassReverse /apex/
    ProxyHTMLURLMap /       /apex/
    ProxyHTMLURLMap /apex  /apex
    ProxyHTMLURLMap /apex/ /apex/
    ProxyHTMLDocType '<!DOCTYPE html>'
 </Location>

As a result I get the JSON Data now labeled as "application/json", but also HTML-Filtered with the "<html><body>..." tags. In addition both "X-Rule…" Headers ("X-Rule-apex" and "X-Rule-apex-wwv_flow.show") are set in the arriving Data Package which means that both <Location> Rules were applied.

  • Is there any way to tell mod_proxy only to apply <Location "/apex/wwv_flow.show"> if it fits and then stop?
  • Is it possible to deactivate the fixing of "malformed" html data (globally)? I didn't find anything.
  • Is it possible to tell <Location /apex/> to stop processing if the url contains "wwv_flow.show"? Also didn't find anything.
  • Or is there any other option I can't think of to solve the problem?
1

Split your location into two sections:


1. <Location /apex/> - here you should put ProxyPassReverse options.
2. <Location /apex/(?!wwv_flow\.show)> - this one will match everything other then /apex/wwv_flow.show


First section is required because ProxyPassReverse takes location literally and will go crazy on regex. If you encounter such problems with different directives just move them here.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.