title: How to preserve the Content-Type header of a Tomcat HTTP response sent through an AJP connector to Apache using mod_proxy
body: <p>I'm having a problem with an incorrect HTTP Response <code>Content-Type</code> header while accessing an Axis2 web service hosted in Tomcat behind Apache through an AJP/1.3 connector.</p>
  
  <p>I can access the web service without problems in the browser through its RESTful interface and I can see the results but somehow Apache is changing the response <code>Content-Type</code> header sent by Tomcat from <code>text/xml</code> to <code>text/plain</code> and it prevents me from consuming the web service through SOAP in NetBeans, because of an <code>Unsupported Content-Type: text/plain Supported ones are: [text/xml]</code> exception.</p>
  
  <p>Here's the relevant section of my Apache vhosts configuration:</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      ServerAdmin me@myserver.example
      ServerName  myserver.example
      ServerAlias other.myserver.example
  
      ProxyPreserveHost On 
      SetEnv force-proxy-request-1.0 1
      SetEnv proxy-nokeepalive 1
  
      &lt;Location /axis2/services&gt;
          ProxyPass ajp://localhost:8009/axis2/services
          ProxyPassReverse ajp://localhost:8009/axis2/services
      &lt;/Location&gt;
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>And the relevant section of my Tomcat server.xml:</p>
  
  <pre><code>&lt;Connector port="8009" protocol="AJP/1.3" redirectPort="9443" /&gt;
  
  &lt;Connector port="9443" protocol="HTTP/1.1" SSLEnabled="true" maxHttpHeaderSize="8192"
      maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
      enableLookups="false" disableUploadTimeout="true"
      acceptCount="100" scheme="https" secure="true"
      clientAuth="false" sslProtocol="TLS"
      SSLCertificateFile="path/to/bundle" 
      SSLCertificateKeyFile="path/to/key"
      SSLPassword="S3cr3t"
      proxyName="myserver.example" proxyPort="443" /&gt;
  </code></pre>
  
  <p>If I access the WS directly in Tomcat using the default connector on port 8080 I get the correct <code>content-type</code> but if I access it through Apache then I get <code>text/plain</code>, so it's definitely a problem with the proxy.</p>
  
  <p>How can I solve this problem?</p>
  
  <p><strong>EDIT:</strong> I got it to work by using the Tomcat HTTP connector for the proxying, instead of the AJP one, but I would prefer to use mod_ajp if I find a working solution.</p>
  
  <p>I just changed the</p>
  
  <pre><code>ProxyPass ajp://localhost:8009/axis2/services
  ProxyPassReverse ajp://localhost:8009/axis2/services
  </code></pre>
  
  <p>lines to</p>
  
  <pre><code>ProxyPass http://localhost:8080/axis2/services
  ProxyPassReverse http://localhost:8080/axis2/services
  </code></pre>