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
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
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., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho