tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: url prefixes behind proxy
Date Thu, 06 Jan 2011 21:23:25 GMT
Hash: SHA1


On 1/6/2011 2:38 PM, gabor wrote:
> Tomcat is version 6.0, but it is highly experimental under my hands ;-)

6.0.what? We're just dying to know.

>> You have configured* the proxy to expect Tomcat to have either tom.war
>> or a directory deployed in tomcat/webapps called 'tom'.
>> e.g
>>   path/to/tomcat/webapps/tom.war
>> or
>>   path/to/tomcat/webapps/tom/
> Oh, I'm sorry not to say that.
> I would like to access Tomcat root through url http://localhost:80/tom/ .

No, you want to access the "tom" webapp through URL

> Say, to change the textbook example:
> http://localhost:8080/     ->   path/to/tomcat/webapps/

Unless you have butchered your configuration, the above path
(path/to/tomcat/webapps/) does not contain a webapp. Instead, it
contains directories where webapps live. Can you try this instead:

http://localhost:8080/tom     ->   path/to/tomcat/webapps/tom

> to:
> http://localhost:80/tom/     ->   path/to/tomcat/webapps/

My example above is better because it will actually work.

> Probably the more difficult part is when a webapp publishes a link,
> (e.g., to a .jpg) without the prefix /tom/  -> which in turn is not proxy
> redirected by nginx to Tomcat... (404.htm)

So... do you want URLs of the form /not_tom/whatever.jpg to be
redirected to your /tom context, or are you saying that NginX should
send those requests elsewhere and so Tomcat doesn't care about them?

> I'm thinking to use a prefix to redirect because
> - I am going to have only port 80 open for the public

Not really relevant, but understandable.

> - there are also some static (+a few php) pages

Also not a problem: all of this can be handled with NginX by only
mapping appropriate requests to Tomcat, regardless of their URL prefix.

> (would be great just leave them as they are now)
> - there is also an
> nginx --> apache --> django
> setup on the server (working just fine).

Aah, unnecessary complexity: I just love it.

> Django serves from behind a prefix, that's why I thought to approach
> Tomcat in a similar fashion.

Fine. Just deploy your webapp as /tom and be done with it. It will work
exactly as you'd like it to. It's the simplest possible thing you could
do, and it meets your needs.

> Well, basically I use the default server.xml.
> Only the <Host> tag is hacked as described above.

Undo that and go back to default server.xml. Then, put your "tom" webapp
under path/to/tomcat/webapps/tom. Restart Tomcat and everything should
work as desired.

- -chris
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message