You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Gabor Pinter <g-...@pearl.kobe-u.ac.jp> on 2011/01/06 12:02:56 UTC

url prefixes behind proxy

Dear list,

I have a very trivial problem.

My setup:
CentOS 5.5
nginx 0.8.53
Tomcat6

net ---> nginx:80 (proxy_pass) ---> tomcat:8080

Proxy redirect is triggered by prefix "/tom/"

myhost:80/tom/<url>  --->  127.0.0.1:8080/tom/<url>

Now here is my question.
How can I let Tomcat know about this "/tom/" prefix?

<Host name="localhost/tom" ...  seems to work in a somewhat confusing manner

The Tomcat welcome page ignores prefix /tom/ in links
(hence, no pix + links are wrong ).
However, in apps (e.g. 'manager', 'examples') links are prefixed by 
/tom/ (so pix & links are fine).


What is the authentic way to make the prefix absolutely transparent?

Thanks in advance!

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: url prefixes behind proxy

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Gabor,

On 1/6/2011 11:54 PM, Gabor Pinter wrote:
> Dear Christopher,
> 
> Thank you for your reply.
> 
>>> Tomcat is version 6.0
>>
>> 6.0.what? We're just dying to know.
> 
> Sorry, it's 6.0.29 .
> (Though at my level, the third digit may be of minor importance :)

It's always good to check that you're not running 6.0.17 or some other
version that was never actually released.

>> http://localhost:8080/tom     ->    path/to/tomcat/webapps/tom
>>> http://localhost:80/tom/     ->    path/to/tomcat/webapps/
>>
>> My example above is better because it will actually work.
> 
> I can see that.
> But doesn't this mean that you need to add a proxy_pass for each app you
> deploy under webapp?

You will need a ProxyPass for each logical URL group you want to send to
Tomcat. If you want to send everything to Tomcat, you can just do:

ProxyPass / ajp://localhost/

You could also put everything behind another URL prefix... something like:

ProxyPass /webapps ajp://localhost/webapps

Then, you'd want to deploy your webapps like this:

webapps/webapps#tom.war
webapps/webapps#foo.war
webapps/webapps#bar (a directory example)

> Plus the root app in Tomcat also needed to be moved from "/".

What do you need the root app for?

> I can live with that, I'm just curious if it is possible to use
> a global prefix ('/tom' is a bad example, say '/servlet') for a
> redirection.

Okay:

ProxyPass /servlet ajp://localhost/servlet

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

Note that you never map a URL to a directory. You map it to a webapp
which is deployed on that URL. path/to/tomcat/webapps is not a webapp,
it's a directory that is treated specially by the default Tomcat
configuration by auto-deploying webapps that appear there as directories
or .war files.

If you use "ProxyPass /servlet ajp://localhost/servlet" then you'll want
to make sure that your webapps are deployed into contexts with a
/servlet prefix. You do that using servlet#webappname.war (or without
the .war if it's an exploded WAR file). If you want
http://localhost:8080/servlet/tom to take you to the "tom" webapp,
you'll want to deploy it into:

path/to/tomcat/webapps/servlet#tom.war (or a directory w/o the .war)

>>> nginx -->  apache -->  django
>>> setup on the server (working just fine).
>>
>> Aah, unnecessary complexity: I just love it.
> 
> The concept is from an Apress django book.
> Would you live nginx out? Or Apache?
> Or django?

If you need to mix technologies such as Perl, PHP, python, etc. along
with Java, the simplest way is to use a web proxy such as squid, Apache
httpd, or NginX. It's the combination of everything that seems
overly-complicated to me.

Presumably, django is a requirement. Do you use it under a typical
python environment, or do you use Jython or something like that? If you
are using Jython and everything is running in your webapp, why not dump
all those proxies (httpd and NginX) and just use Tomcat directly?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk0nLqYACgkQ9CaO5/Lv0PD4sACgvN7gHGL9PQ7MfXdAAopvEjcX
rA8An0OA+VNgBaTa82zTLGmT00MRLXK5
=XCL+
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: url prefixes behind proxy

Posted by Gabor Pinter <g-...@pearl.kobe-u.ac.jp>.
Dear Christopher,

Thank you for your reply.

 >> Tomcat is version 6.0
 >
 > 6.0.what? We're just dying to know.

Sorry, it's 6.0.29 .
(Though at my level, the third digit may be of minor importance :)


 > http://localhost:8080/tom     ->    path/to/tomcat/webapps/tom
 >> http://localhost:80/tom/     ->    path/to/tomcat/webapps/
 >
 > My example above is better because it will actually work.

I can see that.
But doesn't this mean that you need to add a proxy_pass for each app you 
deploy under webapp?
Plus the root app in Tomcat also needed to be moved from "/".

I can live with that, I'm just curious if it is possible to use
a global prefix ('/tom' is a bad example, say '/servlet') for a redirection.

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

 >> nginx -->  apache -->  django
 >> setup on the server (working just fine).
 >
 > Aah, unnecessary complexity: I just love it.

The concept is from an Apress django book.
Would you live nginx out? Or Apache?
Or django?

I'm open to any suggestions.

Gabor




On 2011-01-07 06:23, Christopher Schultz wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Gabor,
>
> 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
> http://localhost:80/tom/.
>
>> 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
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk0mMs0ACgkQ9CaO5/Lv0PC4BACeKfmpx57LRtGeLzp8W1uCwIsw
> ToAAoJtw88ZWxerVDLEWq8OhflGxyIl9
> =Pg4c
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: url prefixes behind proxy

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Gabor,

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
http://localhost:80/tom/.

> 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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk0mMs0ACgkQ9CaO5/Lv0PC4BACeKfmpx57LRtGeLzp8W1uCwIsw
ToAAoJtw88ZWxerVDLEWq8OhflGxyIl9
=Pg4c
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: url prefixes behind proxy

Posted by gabor <g-...@pearl.kobe-u.ac.jp>.
On 1/6/2011 8:14 PM, Pid wrote:
> On 1/6/11 11:02 AM, Gabor Pinter wrote:
>> Dear list,
>>
>> I have a very trivial problem.
>>
>> My setup:
>> CentOS 5.5
>> nginx 0.8.53
>> Tomcat6
> You're using the unreleased, but highly experimental and potentially
> dangerous version 6.3.7!?
>
> ;)
First, thank you for your reply.

Tomcat is version 6.0, but it is highly experimental under my hands ;-)


>> net --->  nginx:80 (proxy_pass) --->  tomcat:8080
>>
>> Proxy redirect is triggered by prefix "/tom/"
>>
>> myhost:80/tom/<url>   --->   127.0.0.1:8080/tom/<url>
>>
>> Now here is my question.
>> How can I let Tomcat know about this "/tom/" prefix?
> What do you expect Tomcat to do with the prefix?
>
> 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/ .
Say, to change the textbook example:
http://localhost:8080/     ->   path/to/tomcat/webapps/
to:
http://localhost:80/tom/     ->   path/to/tomcat/webapps/

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)

I'm thinking to use a prefix to redirect because
- I am going to have only port 80 open for the public
- there are also some static (+a few php) pages
(would be great just leave them as they are now)
- there is also an
nginx --> apache --> django
setup on the server (working just fine).

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

>> <Host name="localhost/tom" ...  seems to work in a somewhat confusing
>> manner
> "localhost/tom" isn't valid hostname, nothing surprising about that.
My first surprise was, that it worked at all...

> p
>
> * Assuming a default server.xml - you didn't say...
>
Well, basically I use the default server.xml.
Only the <Host> tag is hacked as described above.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: url prefixes behind proxy

Posted by Pid <pi...@pidster.com>.
On 1/6/11 11:02 AM, Gabor Pinter wrote:
> Dear list,
> 
> I have a very trivial problem.
> 
> My setup:
> CentOS 5.5
> nginx 0.8.53
> Tomcat6

You're using the unreleased, but highly experimental and potentially
dangerous version 6.3.7!?

;)


> net ---> nginx:80 (proxy_pass) ---> tomcat:8080
> 
> Proxy redirect is triggered by prefix "/tom/"
> 
> myhost:80/tom/<url>  --->  127.0.0.1:8080/tom/<url>
> 
> Now here is my question.
> How can I let Tomcat know about this "/tom/" prefix?

What do you expect Tomcat to do with the prefix?

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/


> <Host name="localhost/tom" ...  seems to work in a somewhat confusing
> manner

"localhost/tom" isn't valid hostname, nothing surprising about that.


p

* Assuming a default server.xml - you didn't say...

> The Tomcat welcome page ignores prefix /tom/ in links
> (hence, no pix + links are wrong ).
> However, in apps (e.g. 'manager', 'examples') links are prefixed by
> /tom/ (so pix & links are fine).
> 
> 
> What is the authentic way to make the prefix absolutely transparent?
> 
> Thanks in advance!
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 


Re: url prefixes behind proxy

Posted by Gabor Pinter <g-...@pearl.kobe-u.ac.jp>.
Andre,

Thank you for your detailed description!
It cleared up a lot.

Just let me ask one more question.

A simple proxy_pass results in the following mapping (correct?)

http://hostname:8080/tom/app
   |   proxy_pass to
   |   127.0.0.1:8080/tom/app
   |
(tomcat_dir)/webapps/tom/app


Is there a way to eliminate the '/tom' part as follows?
('eliminate' : make it transparent from Tomcat side)

http://hostname:8080/tom/app
   |   proxy_pass
   |
   |   127.0.0.1:8080/tom/app
   |
   |   Tomcat mapping
(tomcat_dir)/webapps/app


A rewrite in the proxy_pass can remove '/tom',
however links *served* by Tomcat will not have '/tom'.
(-> no proxy -> not found error)

"When the application on the backend returns content including 
self-referential URLs using its own backend address and port, the client 
will usually not be able to use these URLs."
( http://tomcat.apache.org/connectors-doc/generic_howto/proxy.html )

The site above mentions Apache modul 'mod_jk' as a solution.
But my server is nginx, and google gives me approaches
with proxy_pass. Which would be fine IF  mappers on Tomcat side
would/could handle such prefixes.

If not, I guess I can hard-code the prefix into my apps (brrr),
or set up a   nginx --> Apache (mod_jk) --> Tomcat     redirect.
Or?

I am sorry about the 'trivial' label if it was offending.
I am new to Tomcat, chances are my questions seem trivial or nonsense...










On 2011-01-06 21:43, André Warnier wrote:
> Gabor Pinter wrote:
>> Dear list,
>>
>> I have a very trivial problem.
>>
>> My setup:
>> CentOS 5.5
>> nginx 0.8.53
>> Tomcat6
>>
>> net ---> nginx:80 (proxy_pass) ---> tomcat:8080
>>
>> Proxy redirect is triggered by prefix "/tom/"
>>
>> myhost:80/tom/<url> ---> 127.0.0.1:8080/tom/<url>
>>
>> Now here is my question.
>> How can I let Tomcat know about this "/tom/" prefix?
>>
>> <Host name="localhost/tom" ... seems to work in a somewhat confusing
>> manner
>>
>> The Tomcat welcome page ignores prefix /tom/ in links
>> (hence, no pix + links are wrong ).
>> However, in apps (e.g. 'manager', 'examples') links are prefixed by
>> /tom/ (so pix & links are fine).
>>
>>
>> What is the authentic way to make the prefix absolutely transparent?
>>
>
> Hi.
>
> It is not a trivial problem.
> But I think that you are taking this from the wrong perspective.
> You should not need to do anything special in Tomcat (or nginx) to let
> Tomcat know about the /tom/ prefix. It already knows.
> In particular, you should not do
>
> <Host name="localhost/tom" ...
>
> Leave it as it is
>
> <Host name="localhost" ... >
>
> because this has nothing to do with the directories or URLs that Tomcat
> recognises.
> (That's probably why it is "unpredictable").
>
>
> Let'start from the beginning.
>
> In a webserver like Tomcat, or Apache or nginx, there is a notion of
> "URL space".
>
> That is to say, when you have a URL like http://hostname/a/b/c.html, and
> you consider the part after the protocol and hostname (thus here, the
> /a/b/c.html part), you imagine a certain hierarchical sructure so that
> /b is one of the things "below" /a, and /c.html is one of the things
> "below" /a/b.
>
> This webserver runs on a physcial host, and to store the physical
> resource corresponding to /c.html above, it has a filesystem, where this
> file actually lives.
> For example, the above file c.html may in reality be on the disk, in a
> directory like
> /srv/www/host1/docs/a/b/c.html.
>
> Ok so far ?
>
> Now, between the "URL space", and the filesystem on disk, there is a
> certain "mapping" taking place, so that the webserver would know that
> when it receives request for the URL "/a/b/c.html", it should look for
> that file in the directory "/srv/www/host1/docs/a/b/".
> That mapping is done for example under Apache by the configuration line:
>
> DocumentRoot /srv/www/host1/docs
>
> In other words, this tells Apache that a URL = "/" refers to the disk
> directory /srv/www/host1/docs/, and that a URL like "/a" refers to the
> disk directory /srv/www/host1/docs/a/, and so on.
>
> The same kind of mapping occurs in Tomcat, except that in Tomcat it is
> not a
>
> DocumentRoot /xxx
>
> which tells Tomcat how to map URLs to the filesystem.
> It is the "appBase" attribute in the <Host> tag, like :
>
> <Host name="localhost" ... appBase="webapps" ..>
>
> This "webapps" above tells Tomcat that a URL like
> "http://hostname:8080/a/b/c.html", should be mapped to
>
> (tomcat_directory)/webapps/a/b/c.html
>
> The only thing a bit special with Tomcat is respect of this mapping, is
> that for Tomcat, the URL "/" is not mapped directly to
>
> (tomcat_directory)/webapps/
>
> Instead, it is mapped to
>
> (tomcat_directory)/webapps/ROOT/
>
> This "ROOT" name is special, and represents for Tomcat its "default
> application".
> In other words, for the URL : http://hostname:8080/a.html, Tomcat will
> return the file
> (tomcat_dir)/webapps/ROOT/a.html
>
> Now, to get back to your initial question :
>
> If in nginx, you are telling nginx to pass the following URLs to Tomcat :
>
> myhost:80/tom/<url> ---> 127.0.0.1:8080/tom/<url>
>
> then for a URL like :
>
> http://myhost:80/tom/something.html,
>
> nginx will forward it to Tomcat, and Tomcat will be looking for the file
>
> (tomcat_dir)/webapps/tom/something.html
>
> Automatically. Without having to do anything special in Tomcat.
>
>
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: url prefixes behind proxy

Posted by André Warnier <aw...@ice-sa.com>.
Gabor Pinter wrote:
> Dear list,
> 
> I have a very trivial problem.
> 
> My setup:
> CentOS 5.5
> nginx 0.8.53
> Tomcat6
> 
> net ---> nginx:80 (proxy_pass) ---> tomcat:8080
> 
> Proxy redirect is triggered by prefix "/tom/"
> 
> myhost:80/tom/<url>  --->  127.0.0.1:8080/tom/<url>
> 
> Now here is my question.
> How can I let Tomcat know about this "/tom/" prefix?
> 
> <Host name="localhost/tom" ...  seems to work in a somewhat confusing 
> manner
> 
> The Tomcat welcome page ignores prefix /tom/ in links
> (hence, no pix + links are wrong ).
> However, in apps (e.g. 'manager', 'examples') links are prefixed by 
> /tom/ (so pix & links are fine).
> 
> 
> What is the authentic way to make the prefix absolutely transparent?
> 

Hi.

It is not a trivial problem.
But I think that you are taking this from the wrong perspective.
You should not need to do anything special in Tomcat (or nginx) to let Tomcat know about 
the /tom/ prefix. It already knows.
In particular, you should not do

<Host name="localhost/tom" ...

Leave it as it is

<Host name="localhost" ... >

because this has nothing to do with the directories or URLs that Tomcat recognises.
(That's probably why it is "unpredictable").


Let'start from the beginning.

In a webserver like Tomcat, or Apache or nginx, there is a notion of "URL space".

That is to say, when you have a URL like http://hostname/a/b/c.html, and you consider the 
part after the protocol and hostname (thus here, the /a/b/c.html part), you imagine a 
certain hierarchical sructure so that /b is one of the things "below" /a, and /c.html is 
one of the things "below" /a/b.

This webserver runs on a physcial host, and to store the physical resource corresponding 
to /c.html above, it has a filesystem, where this file actually lives.
For example, the above file c.html may in reality be on the disk, in a directory like
/srv/www/host1/docs/a/b/c.html.

Ok so far ?

Now, between the "URL space", and the filesystem on disk, there is a certain "mapping" 
taking place, so that the webserver would know that when it receives  request for the URL 
"/a/b/c.html", it should look for that file in the directory "/srv/www/host1/docs/a/b/".
That mapping is done for example under Apache by the configuration line:

DocumentRoot /srv/www/host1/docs

In other words, this tells Apache that a URL = "/" refers to the disk directory 
/srv/www/host1/docs/, and that a URL like "/a" refers to the disk directory 
/srv/www/host1/docs/a/, and so on.

The same kind of mapping occurs in Tomcat, except that in Tomcat it is not a

DocumentRoot /xxx

which tells Tomcat how to map URLs to the filesystem.
It is the "appBase" attribute in the <Host> tag, like :

<Host name="localhost" ... appBase="webapps" ..>

This "webapps" above tells Tomcat that a URL like "http://hostname:8080/a/b/c.html", 
should be mapped to

(tomcat_directory)/webapps/a/b/c.html

The only thing a bit special with Tomcat is respect of this mapping, is that for Tomcat, 
the URL "/" is not mapped directly to

(tomcat_directory)/webapps/

Instead, it is mapped to

(tomcat_directory)/webapps/ROOT/

This "ROOT" name is special, and represents for Tomcat its "default application".
In other words, for the URL : http://hostname:8080/a.html, Tomcat will return the file
(tomcat_dir)/webapps/ROOT/a.html

Now, to get back to your initial question :

If in nginx, you are telling nginx to pass the following URLs to Tomcat :

myhost:80/tom/<url>  --->  127.0.0.1:8080/tom/<url>

then for a URL like :

http://myhost:80/tom/something.html,

nginx will forward it to Tomcat, and Tomcat will be looking for the file

(tomcat_dir)/webapps/tom/something.html

Automatically.  Without having to do anything special in Tomcat.









---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org