views:

48

answers:

2

I have a Tomcat 6 webserver running my application and I am seeing some very strange redirect behaviour.

I expect to access my application at the internal URL http://appteam.testdomain.co.uk/test and that this will return a 302 redirect to http://appteam.testdomain.co.uk/test/ which then serves up index.html, the front page of the application.

However, a GET for http://appteam.testdomain.co.uk/test currently returns a 302 to http://appteam.testdomain.co.ukteam.testdomain.co.uk/test/

How would I debug this weird redirect and what Tomcat config could possibly be causing this behaviour?

EDIT

For clarity the strangeness here is that a request for

http://appteam.testdomain.co.uk/test 

is being redirected to

http://appteam.testdomain.co.ukteam.testdomain.co.uk/test/

Note the mangled domain.

EDIT2

@Sean - I am not doing the redirect myself. Something deep within Tomcat seems to be handling this for me. Let me know which parts of the various Tomcat XML files would help to diagnose this and I will post them.

A: 

This behaviour seems not to be an error. Jetty also sends a 302 redirect if the request points to a directory without the trailing slash.

The Apache URL Rewriting Guide contains a section about the Trailing Slash Problem.

vanje
Thanks for the quick answer but my real concern is about the domain being mangled - see my edit above.
mchr
Oh, sorry, I overlooked this part of your question. Then my answer is useless for you.
vanje
A: 

I have worked out the answer and it is very specific to the way my app is deployed. Tomcat sits behind an NGINX proxy which forwards almost all traffic to Tomcat. The Proxy is used to handle some URLs differently. It turns out that Tomcat is returning a correct 302 to

http://appteam.testdomain.co.uk/test/

but the NGINX proxy is mangling this into

http://appteam.testdomain.co.ukteam.testdomain.co.uk/test/
mchr