Unexpected Content-Type Response

10 views
Skip to first unread message

Andy Arismendi

unread,
Jan 23, 2023, 6:13:42 PM1/23/23
to membrane-monitor
Hi, I'm trying to put a membrane serviceProxy in front of a third part nodejs application that runs on a non standard port. I've been trying different proxy.xml configuration and have it working with a URL context that includes a trailing slash e.g. /survey123/ but only partially working without a trailing slash e.g. /survey123. The issue that is happening with the latter is the javascript file Content-Type response headers are being set to text/html instead of application/javascript. I have no clue why this is happening. Any help would be appreciated! Here is my config (note the comments). Also note it's running as a WAR on Tomcat under webapps/survey123.

<?xml version="1.0" encoding="UTF-8"?>

<spring:beans xmlns="http://membrane-soa.org/proxies/1/"

   xmlns:spring="http://www.springframework.org/schema/beans"

   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

   xmlns:web="http://membrane-soa.org/war/1/"

   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd          http://membrane-soa.org/proxies/1/ http://membrane-soa.org/schemas/proxies-1.xsd          http://membrane-soa.org/war/1/ http://membrane-soa.org/schemas/war-1.xsd">

   <router hotDeploy="false">

       <web:servletTransport id="transport" removeContextRoot="true" />

       <serviceProxy>

           <reverseProxying />

           <response>

               <!-- replace html <base href="/"/> tag with <base href="/survey123/"/> -->

               <regExReplacer

                   regex="&lt;base\s+href\s*=\s*\&quot;/\&quot;\s*[\s/]*?&gt;"

                   replace="&lt;base href=&quot;/survey123/&quot; /&gt;" />

           </response>


           <!-- works for /survey123/ but not without trailing slash /survey123 -->

           <target host="upstream-server.domain.local" port="5443">

               <ssl />

           </target>


           <!-- works for /survey123 but javascript Content-Type response are incorrect -->

           <!-- Direct to 5443 gives

                   Content-Type: application/javascript; charset=UTF-8

                Proxy instead gives

                   Content-Type: text/html;charset=UTF-8

           -->

           <target url="https://upstream-server.domain.local:5443/">

               <ssl />

           </target>

       </serviceProxy>

   </router>

</spring:beans>

Andy Arismendi

unread,
Jan 23, 2023, 11:09:27 PM1/23/23
to membrane-monitor
I got something working, in web.xml I changed the url pattern from /* to / which started causing a 302 redirect to /survey123/ which worked with the serviceProxy.

web.xml
    <servlet-mapping>
        <servlet-name>membrane</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

proxies.xml
      <target host="upstream-server.domain.local" port="5443">
           <ssl />
      </target>

Andy Arismendi

unread,
Jan 23, 2023, 11:14:11 PM1/23/23
to membrane-monitor

Looks like in addition to the above I also needed removeContextRoot="true" in proxies.xml.

        <web:servletTransport id="transport" removeContextRoot="true">
Reply all
Reply to author
Forward
0 new messages