Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Httpd to Tomcat, Proxy, code 302 problems

Posted by admin (Graham Ellis), 15 August 2004
Scenario (an issue that came up during last week's course on one of the systems and I "could see for looking")

* Apache httpd running on port 80 of a server called "Thursday"
* Apache tomcat also runninng on "Thurdays"
* Requests to the /shop directory on httpd to be forwarded to the /cycleshop webapp on Tomcat via Proxy port 7476

* All worked fine for requests /shop/ (note trailing /) and anything withing /shop, but failed for /shop with no trailing /.

Configuration file - pertinent information:

httpd.conf includes
Code:
ProxyPass /shop http://thursday:7476/cycleshop

ProxyPassReverse /shop http://thursday:7476/cycleshop


server.xml includes
Code:
<Connector port="7476"
              maxThreads="150"
              minSpareThreads="25"
              maxSpareThreads="75"
              enableLookups="false"
              acceptCount="100"
              debug="0"
              proxyPort="80"
              connectionTimeout="20000"
              disableUploadTimeout="true" />


Analysis.

Requests for directories without a trailing / result in an http code 302 (moved temporarily) being returned, and the bowser then looks up the returned location.  Here's this demonstrated with telnet:

Code:
earth-wind-and-fire:~/aug04 grahamellis$ telnet thursday 80
Trying 192.168.200.144...
Connected to thursday.
Escape character is '^]'.
GET /shop HTTP/1.0

HTTP/1.1 302 Moved Temporarily
Date: Sun, 15 Aug 2004 13:11:27 GMT
Server: Apache-Coyote/1.1
Location: http://thursday/cycleshop/
Content-Length: 0
Connection: close
Content-Type: text/plain; charset=ISO-8859-1

Connection closed by foreign host.


The proxyPort attribute in the coyote connector configuration rewrites the response as if the request was on port 80, so that the httpd does NOT use its ProxyPassReverse as the URL does not match.

By REMOVING the proxyPort setting from server.xml, the response for the request for the directory /shop now reads:

Code:
earth-wind-and-fire:~/aug04 grahamellis$ telnet thursday 80
Trying 192.168.200.144...
Connected to thursday.
Escape character is '^]'.
GET /shop HTTP/1.0

HTTP/1.1 302 Moved Temporarily
Date: Sun, 15 Aug 2004 13:57:12 GMT
Server: Apache-Coyote/1.1
Location: http://thursday/shop/
Content-Length: 0
Connection: close
Content-Type: text/plain; charset=ISO-8859-1

Connection closed by foreign host.
earth-wind-and-fire:~/aug04 grahamellis$


which is a correctly rewritten URL both forwards and backwards.  When the Browser requests the file at the location to which it has been moved, this operation is now correct.



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2010: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 344596 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho