Thursday, November 28, 2013

Tomcat

FYI, Tomcat always does absolute redirects. This can be a problem if you're behind a reverse proxy. Even if you don't write a line of code, under the hood something like this will happen when someone requests a url like http://site.com/folder which must 302 redirect to http://site.com/folder/

ServletResponse response
response.sendRedirect(responseURL);

And from grepcode we can see that becomes an absolute URL

public void sendRedirect(String location) throws IOException
{
   String absolute = toAbsolute(location);
   setHeader("Location", absolute);
}

Hence the need for ProxyPassReverse when your tomcat is behind a front-end apache on a different box.

{ "loggedin": false, "owner": false, "avatar": "", "render": "nothing", "trackingID": "UA-36983794-1", "description": "", "page": { "blogIds": [ 470 ] }, "domain": "holtstrom.com", "base": "\/michael", "url": "https:\/\/holtstrom.com\/michael\/", "frameworkFiles": "https:\/\/holtstrom.com\/michael\/_framework\/_files.4\/", "commonFiles": "https:\/\/holtstrom.com\/michael\/_common\/_files.3\/", "mediaFiles": "https:\/\/holtstrom.com\/michael\/media\/_files.3\/", "tmdbUrl": "http:\/\/www.themoviedb.org\/", "tmdbPoster": "http:\/\/image.tmdb.org\/t\/p\/w342" }