You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Eldon Olmstead <el...@ns.sympatico.ca> on 2011/10/22 18:11:46 UTC

URI mapping

Hello,

I'm using the following
Apache2.2
mod_jk 1.2.32
Tomcat 7.0.21

I am trying to understand how to configure Apache to allow access to 
Tomcat via mod_jk. I have already made some progress, but have got stuck 
on one point.

Currently, I can access Apache at http://localhost ( works )
I can also access tomcats default wepapp and the manager and 
host-manager via

http://localhost:8080/
http://localhost:8080/manager
http://localhost:8080/host-manager


What I want to do next it to connect Apache to Tomcat via mod_jk such 
that the following URLs work

http://localhost/tomcat7/ ( default tomcat webapp)
http://localhost/tomcat7/manager
http://localhost/tomcat7/host-manager


I have updated the workers.properties with:

    worker.list=tomcat7
    worker.tomcat7.type=ajp13
    worker.tomcat7.host=localhost
    worker.tomcat7.port=8809

I have added the the following in my http-jk.conf that I include in 
http.conf:

    JkMount  /tomcat7/* tomcat7

When I try to access http://localhost/tomcat7, tomcat is given the URI 
/tomcat7/

    127.0.0.1 - - [22/Oct/2011:11:34:20 -0300] "GET /tomcat7/ HTTP/1.1"
    404 979

So from the above log, I know that apache is forwarding the requests to 
tomcat via mod_jk ok, but tomcat now thinks that /tomcat7/ is now part 
of the request and since there is no tomcat7 web app, it doesn't match 
the request.

I would like http://localhost/tomcat7/ to map to the root of my Tomcat, 
and to be able to access http://localhost/tomcat7/manager, 
http://localhost/tomcat7/host-manager.

What do I do next?

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


Re: URI mapping

Posted by André Warnier <aw...@ice-sa.com>.
Hi.

What response ? to what question ?

Top-posting makes it difficult to follow the flow of questions/answers.
Mark's response was at the bottom, where it was logically following the part of the 
question he was answering.  Once it has started that way, it is a lot easier for everyone 
to continue the same way.
See next message.

Eldon Olmstead wrote:
> Thanks for the response Mark,
> 
> Ok so if I want to keep mod_jk as part of this, ( it is what we use at 
> work ), then if I understand right, I have no choice but to make tomcat 
> support /tomcat7/ in the path. Do I do this just by moving all the 
> webapps under webapps/tomcat7/? Will I have to make other configuration 
> changes?
> 
> What is the right way to do this? The way we have it at work is that 
> each tomcat worker is pointing to one developer's tomcat installation 
> for the developer to do with as they need.
> 
> On 2011-10-22 1:17 PM, Mark Thomas wrote:
>> On 22/10/2011 17:11, Eldon Olmstead wrote:
>>> Hello,
>>>
>>> I'm using the following
>>> Apache2.2
>>> mod_jk 1.2.32
>>> Tomcat 7.0.21
>>>
>>> I am trying to understand how to configure Apache to allow access to
>>> Tomcat via mod_jk. I have already made some progress, but have got stuck
>>> on one point.
>>>
>>> Currently, I can access Apache at http://localhost ( works )
>>> I can also access tomcats default wepapp and the manager and
>>> host-manager via
>>>
>>> http://localhost:8080/
>>> http://localhost:8080/manager
>>> http://localhost:8080/host-manager
>>>
>>>
>>> What I want to do next it to connect Apache to Tomcat via mod_jk such
>>> that the following URLs work
>>>
>>> http://localhost/tomcat7/ ( default tomcat webapp)
>>> http://localhost/tomcat7/manager
>>> http://localhost/tomcat7/host-manager
>>>
>>>
>>> I have updated the workers.properties with:
>>>
>>>     worker.list=tomcat7
>>>     worker.tomcat7.type=ajp13
>>>     worker.tomcat7.host=localhost
>>>     worker.tomcat7.port=8809
>>>
>>> I have added the the following in my http-jk.conf that I include in
>>> http.conf:
>>>
>>>     JkMount  /tomcat7/* tomcat7
>>>
>>> When I try to access http://localhost/tomcat7, tomcat is given the URI
>>> /tomcat7/
>>>
>>>     127.0.0.1 - - [22/Oct/2011:11:34:20 -0300] "GET /tomcat7/ HTTP/1.1"
>>>     404 979
>>>
>>> So from the above log, I know that apache is forwarding the requests to
>>> tomcat via mod_jk ok, but tomcat now thinks that /tomcat7/ is now part
>>> of the request and since there is no tomcat7 web app, it doesn't match
>>> the request.
>>>
>>> I would like http://localhost/tomcat7/ to map to the root of my Tomcat,
>>> and to be able to access http://localhost/tomcat7/manager,
>>> http://localhost/tomcat7/host-manager.
>>>
>>> What do I do next?
>> If you want to modify the URL, you'll need to use mod_proxy. Then you
>> can do:
>>
>> ProxyPass /tomcat7 http://localhost:8080
>> or
>> ProxyPass /tomcat7 ajp://localhost:8080
>>
>> Note that as soon as you start modifying the URL as part of the
>> ProxyPass you open up a world of opportunity for things to go wrong
>> (redirects, cookie paths, links). All of these are fixable but it is a
>> lot easier just to use the same URL structure in both httpd and Tomcat.
>>
>> Mark
>>
>> ---------------------------------------------------------------------
>> 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
> 
> 


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


Re: URI mapping

Posted by Rainer Jung <ra...@kippdata.de>.
On 22.10.2011 18:42, Eldon Olmstead wrote:
> Thanks for the response Mark,
> 
> Ok so if I want to keep mod_jk as part of this, ( it is what we use at
> work ), then if I understand right, I have no choice but to make tomcat
> support /tomcat7/ in the path. Do I do this just by moving all the
> webapps under webapps/tomcat7/? Will I have to make other configuration
> changes?
> 
> What is the right way to do this? The way we have it at work is that
> each tomcat worker is pointing to one developer's tomcat installation
> for the developer to do with as they need.

You might also want to have a look at

http://tomcat.apache.org/connectors-doc/generic_howto/proxy.html

Regards,

Rainer


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


Re: URI mapping

Posted by André Warnier <aw...@ice-sa.com>.
Mark Eggers wrote:
> ----- Original Message -----
> 
>> From: André Warnier <aw...@ice-sa.com>
>> To: Tomcat Users List <us...@tomcat.apache.org>
>> Cc: 
>> Sent: Sunday, October 23, 2011 5:08 AM
>> Subject: Re: URI mapping
>>
>> Let's restart from the beginning.
>>
>> You have, say, 3 Tomcat servers running, and for the sake of the example 
>> let's say that these are
>> - a Tomcat 5.x server
>> - a Tomcat 6.x server
>> - a Tomcat 7.x server
>>
>> You want to run the same applications on all of them (with identical names on 
>> each server), because for instance these are test servers serving to verify that 
>> a given application runs fine under each of these Tomcat versions.
>>
>> You want to be able to choose which Tomcat server you are accessing, by means of 
>> some URI prefix.
>> Example :
>> a request with URI "http://myhost/tomcat7/webapp1" should be forwarded 
>> to webapp1 on Tomcat7, while a request with URI 
>> "http://myhost/tomcat5/webapp1" should be forwarded to Tomcat5.
>>
>> Of course, once "inside" the respective Tomcat, you want this prefix 
>> to have been removed, so that the applications inside this Tomcat look similar 
>> to the same ones in other Tomcats, name-wise.
>> Example :
>> a request with URI "http://myhost/tomcat7/webapp1" should be forwarded 
>> to webapp1 on Tomcat7, whith a request URI of "/webapp1" (and not 
>> "/tomcat7/webapp1").
>>
>> For this, you set up a front-end proxy Apache httpd, which should forward the 
>> requests to individual Tomcats in function of the URI prefix, and strip this 
>> prefix while doing so.
>>
>> Preferably, you would like to do the proxying via mod_jk.
>>
>> That is a problem, because the standard proxying instructions of mod_jk (JkMount 
>> e.g.), do not provide a syntax for forwarding URI's, and modifying these 
>> URIs at the same time.
>>
>> That is why Mark originally oriented you to mod_proxy and mod_proxy_ajp, which 
>> can do that, for example as :
>>
>> ProxyPass /tomcat7 ajp://tomcat7-host:8017
>> ProxyPass /tomcat6 ajp://tomcat6-host:8016
>> ProxyPass /tomcat5 ajp://tomcat7-host:8015
>> (and have each Tomcat listen on the apropriate port with its AJP Connector)
>>
>> Using the above, a request with URI "http://myhost/tomcat7/webapp1" 
>> will be forwarded to the tomcat7 server with a URI of "/webapp1", 
>> while a request with URI "http://myhost/tomcat5/webapp1" will be 
>> forwarded to the tomcat5 server with a URI (also) of "/webapp1".
>>
>> As far as I understand, this is what you want to achieve (although it is not via 
>> mod_jk, but via mod_proxy_ajp instead).
>>
>> Mark however pointed out the drawbacks of modifying the URI : when one of these 
>> applications generates a self-referencing URI, it will not by default re-insert 
>> the stripped host prefix.  For example, if application "/webapp1" on 
>> tomcat7 creates a page with a link to itself like 
>> href="/webapp1/something", it will not magically know to make this 
>> into href="/tomcat7/webapp1/something".  And when this link is clicked 
>> in the browser, it will generate a request to 
>> "http://myhost/webapp1/something", and the above Proxy instructions in 
>> the front-end won't know what to do with it and will ignore it.
>>
>> And the same happens with redirects etc..
>> You can overcome this, but it is likely in the end to create more hassle than 
>> you really want.
>>
>> On the other hand, if you do /not/ modify the URI while proxying the call, then 
>> you end up with a much less easy configuration on the side of the Tomcats, as 
>> you have seen before.
>>
>> So maybe let's look at another kind of solution, involving DNS and 
>> VirtualHosts.
>>
>> Would a solution whereby you access the different Tomcats as follows be 
>> acceptable ?
>> - http://myhost-tomcat7.company.com/webapp1 is forwarded to tomcat7's 
>> webapp1
>> - http://myhost-tomcat6.company.com/webapp1 is forwarded to tomcat6's 
>> webapp1
>> - http://myhost-tomcat5.company.com/webapp1 is forwarded to tomcat5's 
>> webapp1
>>
>> If yes, then do as outlined below.
>>
>> For a start, I suppose that you want to have an Apache httpd front-end, and that 
>> the Apache httpd and all tomcats, all run on the same physical host.
>>
>> Step 1 :
>> Suppose that the front-end Apache httpd host is currently known via DNS as 
>> "myhost.company.com".
>> Define 3 additional DNS aliases for it :
>> - myhost-tomcat7.company.com
>> - myhost-tomcat6.company.com
>> - myhost-tomcat5.company.com
>>
>> Step 2 :
>> define 3 new VirtualHost's in the Apache httpd front-end, one each with
>> - ServerName myhost-tomcat7.company.com
>> - ServerName myhost-tomcat6.company.com
>> - ServerName myhost-tomcat5.company.com
>>
>> (I assume that you know how to do that)
>>
>> Step 3 :
>> In each of these VirtualHost configurations, add the following lines :
>> - in the "myhost-tomcat7.company.com" host, add
>>    ProxyPass / ajp://myhost-tomcat7.company.com:8017
>>    ProxyPassReverse / ajp://myhost-tomcat7.company.com:8017
>> (and similarly for the other VirtualHost's)
>>
>> Step 4 :
>> make each of your Tomcats listen on the corresponding AJP port :
>> - tomcat7 listens on port 8017
>> - tomcat6 listens on port 8016
>> - tomcat5 listens on port 8015
>> (in their respective AJP Connector)
>>
>> The advantage of this is that you are no longer modifying the request URI's, 
>> with all the complications that this brings.
>> All you are doing is modifying the hostname:port part, and that only requires a 
>> ProxyPassReverse directive in the httpd front-end, to rewrite possible redirect 
>> headers generated by the Tomcats.
>> Also this way, self-referencing URIs generated by the Tomcats will also work, 
>> without applications modifications.
>> Cookies may still require help, check the http config help for that.
> 
> 
> Andre,
> 
> Your suggestion is how I set up multiple Tomcats (CATALINA_HOME / CATALINA_BASE) and virtual hosts within those Tomcats. I map each of the Tomcat virtual hosts to separate named virtual hosts on Apache HTTPD.
> 
> I use mod_jk, and each virtual host gets its own uriworkermap.properties file. That way I can add and delete Tomcat applications on the fly for each Apache HTTPD virtual host that's mapped to the appropriate Tomcat virtual host.
> 
> 
> Each Apache HTTPD named virtual host forwarded to a single Tomcat uses the same mod_jk <Connector> (although I could add multiple connectors in server.xml).
> 

Yes, there are a number of variations to the scheme, depending on whether httpd and the 
various Tomcats are or not running inside the same host, or whether you want to have 
several virtual hosts in Tomcat.  In this case though, it seemed that the original 
question mentioned different /versions/ of Tomcat, which you cannot really do with virtual 
hosts or with several instances of Tomcat running from the same CATALINA_HOME.
If each Tomcat runs on a separate physical host (or if you have a host with several IP 
addresses, you can have them all using the same AJP port.

> 
> Each Tomcat virtual host mapped to an Apache HTTPD named virtual host gets its own manager application. The access is controlled in part by directives in an Apache HTTPD <Location> block. I suppose I could add another Realm for each Tomcat virtual host to control that host's manager application as well.
> 
> I've tested this set up with simple applications and it seems to work fine. I only have two real issues. One, I don't know any way to combine dynamic Apache HTTPD virtual hosts with mod_jk and JkMount directives. Two, jk-status and jk-manager refer to all mod_jk connections on a particular Apache HTTPD server.
> 
> Neither of these are show-stoppers.
> 
> My question in all of this is about cookies. I gather what you're saying is that if a person accesses the following:
> 
> http://some-host/app (receives cookie)
> 
> Then that cookie could be used in accessing
> 
> http://other-host/app (uses cookie)
> 

The issue about the cookies is that each Tomcat will issue its cookies with its own 
hostname (whatever /it/ thinks that is), and unless you do something, that's how they will 
be sent to the browser.  You may have to tell the proxying httpd that it also needs to 
rewrite this hostname in the cookies returned by Tomcat, to be the name of the 
corresponding httpd VirtualHost.  Otherwise the browser may not re-send the cookie when it 
should.
You should not have that issue when, in Tomcat, you use the same hostname as the 
corresponding httpd VirtualHost; but you may have it in other cases.
I may be getting myself a bit confused here, but I think that this could happen.
Anyway, there is the ProxyPassReverseCookieDomain to fix this.

> if named virtual hosts are used for some-host and other-host (mapping them to the same IP address and port).
> 
> Is this correct?
> 
> If so, I need to investigate how to manage this with Apache HTTPD. I suppose it's also very unlikely (but possible) to get matching session ids from independent Tomcats running in this environment?
> 
> If you have any pointers to the Apache HTTPD documentation concerning this, I would appreciate it (I know, off-topic).
> 


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


Re: URI mapping

Posted by André Warnier <aw...@ice-sa.com>.
Mark Eggers wrote:
> ----- Original Message -----
> 
>> From: André Warnier <aw...@ice-sa.com>
>> To: Tomcat Users List <us...@tomcat.apache.org>
>> Cc: 
>> Sent: Sunday, October 23, 2011 2:26 PM
>> Subject: Re: URI mapping
>>
>> Pid wrote:
>> ...
>> The jsessionid cookie is set with the server
>>>  name of the Tomcat instance, rather than a domain with variable
>>>  subdomains*, unless you have configured it otherwise (Servlet 3.0 only).
>>>
>> Yes, but what /is/ this server name that this Tomcat will be using ?
>> I don't think that is as straightforward as it may look.
>>
>> For example, what will Tomcat put in the cookie if this Tomcat is set up with a 
>> single <Host name="localhost">
>> but it runs on a host whose canonical name is 
>> "someserver.company.com".
>>
>> Does it use the hostname received in the "Host:" header of the 
>> request, even when this hostname does not match any of its <Host> tags ?
>>
>> And what if there is no Host: header ?
> 
> 
> Andre,
> 
> Exactly. Those were some of my questions as well. Right now though I'm setting up all Apache named virtual hosts to Tomcat virtual hosts so that the names match.
> 
> Apache HTTPD
> <VirtualHost *:80>
>   ServerName somehost.somewhere.com
>   ServerAlias somehost
> # more stuff
> </VirtualHost>
> 
> Tomcat server.xml
> <Host name="ahost" appBase="some-absolute-path">
>   <Alias>somehost.somewhere.com</Alias>
>   <!-- more stuff -->
> </Host>
> 
> I don't map the default host (left at localhost). Based on what I've read so far, the cookies should come back in a sane fashion. I may have to flip the Tomcat <Host> name attribute and <Alias> element around to have a completely clean installation. This will make CATALINA_BASE/conf/Catalina/<name> a bit ugly, but I can live with that.
> 
> I should set this up with a test web application with cookies and watch the entire mess with Firedebug.
> 
..
By the way, if you are using mod_jk, you can use an alternative way to forward requests 
from Apache httpd to Tomcat.
Look at the bottom of this page : 
http://tomcat.apache.org/connectors-doc/reference/apache.html
the section entitled "Using SetHandler and Environment Variables".

Instead of using "JkMount /tomcat7/* tomcat7", you can use a Location section like

<Location /tomcat7>
   SetHandler jakarta-servlet
   SetEnv JK_WORKER_NAME=tomcat7
   SetEnvIf REQUEST_URI ..(regexp).. no-jk

...
</Location>

to the same effect.
I personally prefer this kind of configuration over JkMount/JkUnmount, because I find that 
it better "fits" within the Apache httpd configuration style, and it is also easier to 
figure out at what stage of the Apache cycle these directives take place.
And you can also add more "httpd things" in the <Location> section (e.g., authentication 
etc..)

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


Re: URI mapping

Posted by Mark Eggers <it...@yahoo.com>.
----- Original Message -----

> From: André Warnier <aw...@ice-sa.com>
> To: Tomcat Users List <us...@tomcat.apache.org>
> Cc: 
> Sent: Sunday, October 23, 2011 2:26 PM
> Subject: Re: URI mapping
> 
> Pid wrote:
> ...
> The jsessionid cookie is set with the server
>>  name of the Tomcat instance, rather than a domain with variable
>>  subdomains*, unless you have configured it otherwise (Servlet 3.0 only).
>> 
> Yes, but what /is/ this server name that this Tomcat will be using ?
> I don't think that is as straightforward as it may look.
> 
> For example, what will Tomcat put in the cookie if this Tomcat is set up with a 
> single <Host name="localhost">
> but it runs on a host whose canonical name is 
> "someserver.company.com".
> 
> Does it use the hostname received in the "Host:" header of the 
> request, even when this hostname does not match any of its <Host> tags ?
> 
> And what if there is no Host: header ?


Andre,

Exactly. Those were some of my questions as well. Right now though I'm setting up all Apache named virtual hosts to Tomcat virtual hosts so that the names match.

Apache HTTPD
<VirtualHost *:80>
  ServerName somehost.somewhere.com
  ServerAlias somehost
# more stuff
</VirtualHost>

Tomcat server.xml
<Host name="ahost" appBase="some-absolute-path">
  <Alias>somehost.somewhere.com</Alias>
  <!-- more stuff -->
</Host>

I don't map the default host (left at localhost). Based on what I've read so far, the cookies should come back in a sane fashion. I may have to flip the Tomcat <Host> name attribute and <Alias> element around to have a completely clean installation. This will make CATALINA_BASE/conf/Catalina/<name> a bit ugly, but I can live with that.

I should set this up with a test web application with cookies and watch the entire mess with Firedebug.

Thanks for a great discussion.

. . . . just my (less confused) two cents.
/mde/

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


Re: URI mapping

Posted by André Warnier <aw...@ice-sa.com>.
Pid wrote:
...
  The jsessionid cookie is set with the server
> name of the Tomcat instance, rather than a domain with variable
> subdomains*, unless you have configured it otherwise (Servlet 3.0 only).
> 
Yes, but what /is/ this server name that this Tomcat will be using ?
I don't think that is as straightforward as it may look.

For example, what will Tomcat put in the cookie if this Tomcat is set up with a single 
<Host name="localhost">
but it runs on a host whose canonical name is "someserver.company.com".

Does it use the hostname received in the "Host:" header of the request, even when this 
hostname does not match any of its <Host> tags ?

And what if there is no Host: header ?



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


Re: URI mapping

Posted by Pid <pi...@pidster.com>.
On 23/10/2011 20:51, Mark Eggers wrote:
> ----- Original Message -----
> 
>> From: André Warnier <aw...@ice-sa.com>
>> To: Tomcat Users List <us...@tomcat.apache.org>
>> Cc: 
>> Sent: Sunday, October 23, 2011 5:08 AM
>> Subject: Re: URI mapping
>>
>> Let's restart from the beginning.
>>
>> You have, say, 3 Tomcat servers running, and for the sake of the example 
>> let's say that these are
>> - a Tomcat 5.x server
>> - a Tomcat 6.x server
>> - a Tomcat 7.x server
>>
>> You want to run the same applications on all of them (with identical names on 
>> each server), because for instance these are test servers serving to verify that 
>> a given application runs fine under each of these Tomcat versions.
>>
>> You want to be able to choose which Tomcat server you are accessing, by means of 
>> some URI prefix.
>> Example :
>> a request with URI "http://myhost/tomcat7/webapp1" should be forwarded 
>> to webapp1 on Tomcat7, while a request with URI 
>> "http://myhost/tomcat5/webapp1" should be forwarded to Tomcat5.
>>
>> Of course, once "inside" the respective Tomcat, you want this prefix 
>> to have been removed, so that the applications inside this Tomcat look similar 
>> to the same ones in other Tomcats, name-wise.
>> Example :
>> a request with URI "http://myhost/tomcat7/webapp1" should be forwarded 
>> to webapp1 on Tomcat7, whith a request URI of "/webapp1" (and not 
>> "/tomcat7/webapp1").
>>
>> For this, you set up a front-end proxy Apache httpd, which should forward the 
>> requests to individual Tomcats in function of the URI prefix, and strip this 
>> prefix while doing so.
>>
>> Preferably, you would like to do the proxying via mod_jk.
>>
>> That is a problem, because the standard proxying instructions of mod_jk (JkMount 
>> e.g.), do not provide a syntax for forwarding URI's, and modifying these 
>> URIs at the same time.
>>
>> That is why Mark originally oriented you to mod_proxy and mod_proxy_ajp, which 
>> can do that, for example as :
>>
>> ProxyPass /tomcat7 ajp://tomcat7-host:8017
>> ProxyPass /tomcat6 ajp://tomcat6-host:8016
>> ProxyPass /tomcat5 ajp://tomcat7-host:8015
>> (and have each Tomcat listen on the apropriate port with its AJP Connector)
>>
>> Using the above, a request with URI "http://myhost/tomcat7/webapp1" 
>> will be forwarded to the tomcat7 server with a URI of "/webapp1", 
>> while a request with URI "http://myhost/tomcat5/webapp1" will be 
>> forwarded to the tomcat5 server with a URI (also) of "/webapp1".
>>
>> As far as I understand, this is what you want to achieve (although it is not via 
>> mod_jk, but via mod_proxy_ajp instead).
>>
>> Mark however pointed out the drawbacks of modifying the URI : when one of these 
>> applications generates a self-referencing URI, it will not by default re-insert 
>> the stripped host prefix.  For example, if application "/webapp1" on 
>> tomcat7 creates a page with a link to itself like 
>> href="/webapp1/something", it will not magically know to make this 
>> into href="/tomcat7/webapp1/something".  And when this link is clicked 
>> in the browser, it will generate a request to 
>> "http://myhost/webapp1/something", and the above Proxy instructions in 
>> the front-end won't know what to do with it and will ignore it.
>>
>> And the same happens with redirects etc..
>> You can overcome this, but it is likely in the end to create more hassle than 
>> you really want.
>>
>> On the other hand, if you do /not/ modify the URI while proxying the call, then 
>> you end up with a much less easy configuration on the side of the Tomcats, as 
>> you have seen before.
>>
>> So maybe let's look at another kind of solution, involving DNS and 
>> VirtualHosts.
>>
>> Would a solution whereby you access the different Tomcats as follows be 
>> acceptable ?
>> - http://myhost-tomcat7.company.com/webapp1 is forwarded to tomcat7's 
>> webapp1
>> - http://myhost-tomcat6.company.com/webapp1 is forwarded to tomcat6's 
>> webapp1
>> - http://myhost-tomcat5.company.com/webapp1 is forwarded to tomcat5's 
>> webapp1
>>
>> If yes, then do as outlined below.
>>
>> For a start, I suppose that you want to have an Apache httpd front-end, and that 
>> the Apache httpd and all tomcats, all run on the same physical host.
>>
>> Step 1 :
>> Suppose that the front-end Apache httpd host is currently known via DNS as 
>> "myhost.company.com".
>> Define 3 additional DNS aliases for it :
>> - myhost-tomcat7.company.com
>> - myhost-tomcat6.company.com
>> - myhost-tomcat5.company.com
>>
>> Step 2 :
>> define 3 new VirtualHost's in the Apache httpd front-end, one each with
>> - ServerName myhost-tomcat7.company.com
>> - ServerName myhost-tomcat6.company.com
>> - ServerName myhost-tomcat5.company.com
>>
>> (I assume that you know how to do that)
>>
>> Step 3 :
>> In each of these VirtualHost configurations, add the following lines :
>> - in the "myhost-tomcat7.company.com" host, add
>>    ProxyPass / ajp://myhost-tomcat7.company.com:8017
>>    ProxyPassReverse / ajp://myhost-tomcat7.company.com:8017
>> (and similarly for the other VirtualHost's)
>>
>> Step 4 :
>> make each of your Tomcats listen on the corresponding AJP port :
>> - tomcat7 listens on port 8017
>> - tomcat6 listens on port 8016
>> - tomcat5 listens on port 8015
>> (in their respective AJP Connector)
>>
>> The advantage of this is that you are no longer modifying the request URI's, 
>> with all the complications that this brings.
>> All you are doing is modifying the hostname:port part, and that only requires a 
>> ProxyPassReverse directive in the httpd front-end, to rewrite possible redirect 
>> headers generated by the Tomcats.
>> Also this way, self-referencing URIs generated by the Tomcats will also work, 
>> without applications modifications.
>> Cookies may still require help, check the http config help for that.
> 
> 
> Andre,
> 
> Your suggestion is how I set up multiple Tomcats (CATALINA_HOME / CATALINA_BASE) and virtual hosts within those Tomcats. I map each of the Tomcat virtual hosts to separate named virtual hosts on Apache HTTPD.
> 
> I use mod_jk, and each virtual host gets its own uriworkermap.properties file. That way I can add and delete Tomcat applications on the fly for each Apache HTTPD virtual host that's mapped to the appropriate Tomcat virtual host.
> 
> 
> Each Apache HTTPD named virtual host forwarded to a single Tomcat uses the same mod_jk <Connector> (although I could add multiple connectors in server.xml).
> 
> 
> Each Tomcat virtual host mapped to an Apache HTTPD named virtual host gets its own manager application. The access is controlled in part by directives in an Apache HTTPD <Location> block. I suppose I could add another Realm for each Tomcat virtual host to control that host's manager application as well.
> 
> I've tested this set up with simple applications and it seems to work fine. I only have two real issues. One, I don't know any way to combine dynamic Apache HTTPD virtual hosts with mod_jk and JkMount directives. Two, jk-status and jk-manager refer to all mod_jk connections on a particular Apache HTTPD server.
> 
> Neither of these are show-stoppers.
> 
> My question in all of this is about cookies. I gather what you're saying is that if a person accesses the following:
> 
> http://some-host/app (receives cookie)
> 
> Then that cookie could be used in accessing
> 
> http://other-host/app (uses cookie)
> 
> if named virtual hosts are used for some-host and other-host (mapping them to the same IP address and port).
> 
> Is this correct?

No, I don't think so.  You'd need the two hosts to be sub-domains of the
primary cookie domain.  The jsessionid cookie is set with the server
name of the Tomcat instance, rather than a domain with variable
subdomains*, unless you have configured it otherwise (Servlet 3.0 only).


p


* E.g.

variable subdomain:  .example.com
fixed subdomain   :  host.example.com

> If so, I need to investigate how to manage this with Apache HTTPD. I suppose it's also very unlikely (but possible) to get matching session ids from independent Tomcats running in this environment?
> 
> If you have any pointers to the Apache HTTPD documentation concerning this, I would appreciate it (I know, off-topic).
> 
> . . . . just my two (confused) cents
> /mde/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 



Re: URI mapping

Posted by Mark Eggers <it...@yahoo.com>.
----- Original Message -----

> From: André Warnier <aw...@ice-sa.com>
> To: Tomcat Users List <us...@tomcat.apache.org>
> Cc: 
> Sent: Sunday, October 23, 2011 5:08 AM
> Subject: Re: URI mapping
> 
> Let's restart from the beginning.
> 
> You have, say, 3 Tomcat servers running, and for the sake of the example 
> let's say that these are
> - a Tomcat 5.x server
> - a Tomcat 6.x server
> - a Tomcat 7.x server
> 
> You want to run the same applications on all of them (with identical names on 
> each server), because for instance these are test servers serving to verify that 
> a given application runs fine under each of these Tomcat versions.
> 
> You want to be able to choose which Tomcat server you are accessing, by means of 
> some URI prefix.
> Example :
> a request with URI "http://myhost/tomcat7/webapp1" should be forwarded 
> to webapp1 on Tomcat7, while a request with URI 
> "http://myhost/tomcat5/webapp1" should be forwarded to Tomcat5.
> 
> Of course, once "inside" the respective Tomcat, you want this prefix 
> to have been removed, so that the applications inside this Tomcat look similar 
> to the same ones in other Tomcats, name-wise.
> Example :
> a request with URI "http://myhost/tomcat7/webapp1" should be forwarded 
> to webapp1 on Tomcat7, whith a request URI of "/webapp1" (and not 
> "/tomcat7/webapp1").
> 
> For this, you set up a front-end proxy Apache httpd, which should forward the 
> requests to individual Tomcats in function of the URI prefix, and strip this 
> prefix while doing so.
> 
> Preferably, you would like to do the proxying via mod_jk.
> 
> That is a problem, because the standard proxying instructions of mod_jk (JkMount 
> e.g.), do not provide a syntax for forwarding URI's, and modifying these 
> URIs at the same time.
> 
> That is why Mark originally oriented you to mod_proxy and mod_proxy_ajp, which 
> can do that, for example as :
> 
> ProxyPass /tomcat7 ajp://tomcat7-host:8017
> ProxyPass /tomcat6 ajp://tomcat6-host:8016
> ProxyPass /tomcat5 ajp://tomcat7-host:8015
> (and have each Tomcat listen on the apropriate port with its AJP Connector)
> 
> Using the above, a request with URI "http://myhost/tomcat7/webapp1" 
> will be forwarded to the tomcat7 server with a URI of "/webapp1", 
> while a request with URI "http://myhost/tomcat5/webapp1" will be 
> forwarded to the tomcat5 server with a URI (also) of "/webapp1".
> 
> As far as I understand, this is what you want to achieve (although it is not via 
> mod_jk, but via mod_proxy_ajp instead).
> 
> Mark however pointed out the drawbacks of modifying the URI : when one of these 
> applications generates a self-referencing URI, it will not by default re-insert 
> the stripped host prefix.  For example, if application "/webapp1" on 
> tomcat7 creates a page with a link to itself like 
> href="/webapp1/something", it will not magically know to make this 
> into href="/tomcat7/webapp1/something".  And when this link is clicked 
> in the browser, it will generate a request to 
> "http://myhost/webapp1/something", and the above Proxy instructions in 
> the front-end won't know what to do with it and will ignore it.
> 
> And the same happens with redirects etc..
> You can overcome this, but it is likely in the end to create more hassle than 
> you really want.
> 
> On the other hand, if you do /not/ modify the URI while proxying the call, then 
> you end up with a much less easy configuration on the side of the Tomcats, as 
> you have seen before.
> 
> So maybe let's look at another kind of solution, involving DNS and 
> VirtualHosts.
> 
> Would a solution whereby you access the different Tomcats as follows be 
> acceptable ?
> - http://myhost-tomcat7.company.com/webapp1 is forwarded to tomcat7's 
> webapp1
> - http://myhost-tomcat6.company.com/webapp1 is forwarded to tomcat6's 
> webapp1
> - http://myhost-tomcat5.company.com/webapp1 is forwarded to tomcat5's 
> webapp1
> 
> If yes, then do as outlined below.
> 
> For a start, I suppose that you want to have an Apache httpd front-end, and that 
> the Apache httpd and all tomcats, all run on the same physical host.
> 
> Step 1 :
> Suppose that the front-end Apache httpd host is currently known via DNS as 
> "myhost.company.com".
> Define 3 additional DNS aliases for it :
> - myhost-tomcat7.company.com
> - myhost-tomcat6.company.com
> - myhost-tomcat5.company.com
> 
> Step 2 :
> define 3 new VirtualHost's in the Apache httpd front-end, one each with
> - ServerName myhost-tomcat7.company.com
> - ServerName myhost-tomcat6.company.com
> - ServerName myhost-tomcat5.company.com
> 
> (I assume that you know how to do that)
> 
> Step 3 :
> In each of these VirtualHost configurations, add the following lines :
> - in the "myhost-tomcat7.company.com" host, add
>    ProxyPass / ajp://myhost-tomcat7.company.com:8017
>    ProxyPassReverse / ajp://myhost-tomcat7.company.com:8017
> (and similarly for the other VirtualHost's)
> 
> Step 4 :
> make each of your Tomcats listen on the corresponding AJP port :
> - tomcat7 listens on port 8017
> - tomcat6 listens on port 8016
> - tomcat5 listens on port 8015
> (in their respective AJP Connector)
> 
> The advantage of this is that you are no longer modifying the request URI's, 
> with all the complications that this brings.
> All you are doing is modifying the hostname:port part, and that only requires a 
> ProxyPassReverse directive in the httpd front-end, to rewrite possible redirect 
> headers generated by the Tomcats.
> Also this way, self-referencing URIs generated by the Tomcats will also work, 
> without applications modifications.
> Cookies may still require help, check the http config help for that.


Andre,

Your suggestion is how I set up multiple Tomcats (CATALINA_HOME / CATALINA_BASE) and virtual hosts within those Tomcats. I map each of the Tomcat virtual hosts to separate named virtual hosts on Apache HTTPD.

I use mod_jk, and each virtual host gets its own uriworkermap.properties file. That way I can add and delete Tomcat applications on the fly for each Apache HTTPD virtual host that's mapped to the appropriate Tomcat virtual host.


Each Apache HTTPD named virtual host forwarded to a single Tomcat uses the same mod_jk <Connector> (although I could add multiple connectors in server.xml).


Each Tomcat virtual host mapped to an Apache HTTPD named virtual host gets its own manager application. The access is controlled in part by directives in an Apache HTTPD <Location> block. I suppose I could add another Realm for each Tomcat virtual host to control that host's manager application as well.

I've tested this set up with simple applications and it seems to work fine. I only have two real issues. One, I don't know any way to combine dynamic Apache HTTPD virtual hosts with mod_jk and JkMount directives. Two, jk-status and jk-manager refer to all mod_jk connections on a particular Apache HTTPD server.

Neither of these are show-stoppers.

My question in all of this is about cookies. I gather what you're saying is that if a person accesses the following:

http://some-host/app (receives cookie)

Then that cookie could be used in accessing

http://other-host/app (uses cookie)

if named virtual hosts are used for some-host and other-host (mapping them to the same IP address and port).

Is this correct?

If so, I need to investigate how to manage this with Apache HTTPD. I suppose it's also very unlikely (but possible) to get matching session ids from independent Tomcats running in this environment?

If you have any pointers to the Apache HTTPD documentation concerning this, I would appreciate it (I know, off-topic).

. . . . just my two (confused) cents
/mde/

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


Re: URI mapping

Posted by André Warnier <aw...@ice-sa.com>.
Let's restart from the beginning.

You have, say, 3 Tomcat servers running, and for the sake of the example let's say that 
these are
- a Tomcat 5.x server
- a Tomcat 6.x server
- a Tomcat 7.x server

You want to run the same applications on all of them (with identical names on each 
server), because for instance these are test servers serving to verify that a given 
application runs fine under each of these Tomcat versions.

You want to be able to choose which Tomcat server you are accessing, by means of some URI 
prefix.
Example :
a request with URI "http://myhost/tomcat7/webapp1" should be forwarded to webapp1 on 
Tomcat7, while a request with URI "http://myhost/tomcat5/webapp1" should be forwarded to 
Tomcat5.

Of course, once "inside" the respective Tomcat, you want this prefix to have been removed, 
so that the applications inside this Tomcat look similar to the same ones in other 
Tomcats, name-wise.
Example :
a request with URI "http://myhost/tomcat7/webapp1" should be forwarded to webapp1 on 
Tomcat7, whith a request URI of "/webapp1" (and not "/tomcat7/webapp1").

For this, you set up a front-end proxy Apache httpd, which should forward the requests to 
individual Tomcats in function of the URI prefix, and strip this prefix while doing so.

Preferably, you would like to do the proxying via mod_jk.

That is a problem, because the standard proxying instructions of mod_jk (JkMount e.g.), do 
not provide a syntax for forwarding URI's, and modifying these URIs at the same time.

That is why Mark originally oriented you to mod_proxy and mod_proxy_ajp, which can do 
that, for example as :

ProxyPass /tomcat7 ajp://tomcat7-host:8017
ProxyPass /tomcat6 ajp://tomcat6-host:8016
ProxyPass /tomcat5 ajp://tomcat7-host:8015
(and have each Tomcat listen on the apropriate port with its AJP Connector)

Using the above, a request with URI "http://myhost/tomcat7/webapp1" will be forwarded to 
the tomcat7 server with a URI of "/webapp1", while a request with URI 
"http://myhost/tomcat5/webapp1" will be forwarded to the tomcat5 server with a URI (also) 
of "/webapp1".

As far as I understand, this is what you want to achieve (although it is not via mod_jk, 
but via mod_proxy_ajp instead).

Mark however pointed out the drawbacks of modifying the URI : when one of these 
applications generates a self-referencing URI, it will not by default re-insert the 
stripped host prefix.  For example, if application "/webapp1" on tomcat7 creates a page 
with a link to itself like href="/webapp1/something", it will not magically know to make 
this into href="/tomcat7/webapp1/something".  And when this link is clicked in the 
browser, it will generate a request to "http://myhost/webapp1/something", and the above 
Proxy instructions in the front-end won't know what to do with it and will ignore it.

And the same happens with redirects etc..
You can overcome this, but it is likely in the end to create more hassle than you really want.

On the other hand, if you do /not/ modify the URI while proxying the call, then you end up 
with a much less easy configuration on the side of the Tomcats, as you have seen before.

So maybe let's look at another kind of solution, involving DNS and VirtualHosts.

Would a solution whereby you access the different Tomcats as follows be acceptable ?
- http://myhost-tomcat7.company.com/webapp1 is forwarded to tomcat7's webapp1
- http://myhost-tomcat6.company.com/webapp1 is forwarded to tomcat6's webapp1
- http://myhost-tomcat5.company.com/webapp1 is forwarded to tomcat5's webapp1

If yes, then do as outlined below.

For a start, I suppose that you want to have an Apache httpd front-end, and that the 
Apache httpd and all tomcats, all run on the same physical host.

Step 1 :
Suppose that the front-end Apache httpd host is currently known via DNS as 
"myhost.company.com".
Define 3 additional DNS aliases for it :
- myhost-tomcat7.company.com
- myhost-tomcat6.company.com
- myhost-tomcat5.company.com

Step 2 :
define 3 new VirtualHost's in the Apache httpd front-end, one each with
- ServerName myhost-tomcat7.company.com
- ServerName myhost-tomcat6.company.com
- ServerName myhost-tomcat5.company.com

(I assume that you know how to do that)

Step 3 :
In each of these VirtualHost configurations, add the following lines :
- in the "myhost-tomcat7.company.com" host, add
    ProxyPass / ajp://myhost-tomcat7.company.com:8017
    ProxyPassReverse / ajp://myhost-tomcat7.company.com:8017
(and similarly for the other VirtualHost's)

Step 4 :
make each of your Tomcats listen on the corresponding AJP port :
- tomcat7 listens on port 8017
- tomcat6 listens on port 8016
- tomcat5 listens on port 8015
(in their respective AJP Connector)

The advantage of this is that you are no longer modifying the request URI's, with all the 
complications that this brings.
All you are doing is modifying the hostname:port part, and that only requires a 
ProxyPassReverse directive in the httpd front-end, to rewrite possible redirect headers 
generated by the Tomcats.
Also this way, self-referencing URIs generated by the Tomcats will also work, without 
applications modifications.
Cookies may still require help, check the http config help for that.


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


Re: URI mapping

Posted by Pid <pi...@pidster.com>.
On 22/10/2011 23:37, Eldon Olmstead wrote:
> 
> 
> On 2011-10-22 5:57 PM, Pid wrote:
>> On 22/10/2011 17:42, Eldon Olmstead wrote:
>>> Thanks for the response Mark,
>>>
>>> Ok so if I want to keep mod_jk as part of this, ( it is what we use at
>>> work ), then if I understand right, I have no choice but to make tomcat
>>> support /tomcat7/ in the path. Do I do this just by moving all the
>>> webapps under webapps/tomcat7/?
>> No.  The appBase (the 'webapps' dir in your case) is not a document root
>> like HTTPD, it is the location for your apps - their published paths are
>> based on their names (usually).
>>
>> You would have rename the applications, from:
>>
>>   tomcat/webapps/app1.war         - http://host/app1
>>   tomcat/webapps/app2.war         - http://host/app2
>>
>> to:
>>
>>   tomcat/webapps/tomcat7#app1.war - http://host/tomcat7/app1
>>   tomcat/webapps/tomcat7#app2.war - http://host/tomcat7/app2
>>
>> The '#' in the name is translated to a '/' in the path.
>
> OK, so what about the folders that come with Tomcat then? Like ROOT,
> manager, and host-manager? Do I jar those up and name them as
> tomcat7#ROOT.war, tomcat7#manager.war, and tomcat7#host-manager.war?

ROOT is the special name for the default application.  Changing it's
name to tomcat7#ROOT would remove the default app & create a new one on
path: /tomcat7/ROOT

Not what you want.

If the apps are exploded .WAR files (ie, directories) just renaming the
directories as above would be enough.


Having said that: you either need to use mod_proxy so you can map URLs
to non-matching app paths, or put a JkMount line in for each web app.
You're making your life unnecessarily difficult.


> I just tried creating wars for the above but that doesn't work.

What doesn't?  Be precise, please.


> Tomcat's access log is showing apache is passing on the request:
> 127.0.0.1 - - [22/Oct/2011:18:27:06 -0300] "GET /tomcat7 HTTP/1.1" 404 -

The above probably doesn't work because you don't have an app called
'tomcat7'.


> 127.0.0.1 - - [22/Oct/2011:18:27:14 -0300] "GET /tomcat7/ROOT HTTP/1.1"
> 404 -  ( tried this just in case )

It's not clear what you've actually done.


> 127.0.0.1 - - [22/Oct/2011:18:27:21 -0300] "GET /tomcat7/manager
> HTTP/1.1" 404 -

That is the expected result: try '/tomcat7/manager/html'


p

> The apps aren't being found.
>>
>>
>> p
>>
>>> Will I have to make other configuration changes?
>>>
>>> What is the right way to do this? The way we have it at work is that
>>> each tomcat worker is pointing to one developer's tomcat installation
>>> for the developer to do with as they need.
>>>
>>> On 2011-10-22 1:17 PM, Mark Thomas wrote:
>>>> On 22/10/2011 17:11, Eldon Olmstead wrote:
>>>>> Hello,
>>>>>
>>>>> I'm using the following
>>>>> Apache2.2
>>>>> mod_jk 1.2.32
>>>>> Tomcat 7.0.21
>>>>>
>>>>> I am trying to understand how to configure Apache to allow access to
>>>>> Tomcat via mod_jk. I have already made some progress, but have got
>>>>> stuck
>>>>> on one point.
>>>>>
>>>>> Currently, I can access Apache at http://localhost ( works )
>>>>> I can also access tomcats default wepapp and the manager and
>>>>> host-manager via
>>>>>
>>>>> http://localhost:8080/
>>>>> http://localhost:8080/manager
>>>>> http://localhost:8080/host-manager
>>>>>
>>>>>
>>>>> What I want to do next it to connect Apache to Tomcat via mod_jk such
>>>>> that the following URLs work
>>>>>
>>>>> http://localhost/tomcat7/ ( default tomcat webapp)
>>>>> http://localhost/tomcat7/manager
>>>>> http://localhost/tomcat7/host-manager
>>>>>
>>>>>
>>>>> I have updated the workers.properties with:
>>>>>
>>>>>      worker.list=tomcat7
>>>>>      worker.tomcat7.type=ajp13
>>>>>      worker.tomcat7.host=localhost
>>>>>      worker.tomcat7.port=8809
>>>>>
>>>>> I have added the the following in my http-jk.conf that I include in
>>>>> http.conf:
>>>>>
>>>>>      JkMount  /tomcat7/* tomcat7
>>>>>
>>>>> When I try to access http://localhost/tomcat7, tomcat is given the URI
>>>>> /tomcat7/
>>>>>
>>>>>      127.0.0.1 - - [22/Oct/2011:11:34:20 -0300] "GET /tomcat7/
>>>>> HTTP/1.1"
>>>>>      404 979
>>>>>
>>>>> So from the above log, I know that apache is forwarding the
>>>>> requests to
>>>>> tomcat via mod_jk ok, but tomcat now thinks that /tomcat7/ is now part
>>>>> of the request and since there is no tomcat7 web app, it doesn't match
>>>>> the request.
>>>>>
>>>>> I would like http://localhost/tomcat7/ to map to the root of my
>>>>> Tomcat,
>>>>> and to be able to access http://localhost/tomcat7/manager,
>>>>> http://localhost/tomcat7/host-manager.
>>>>>
>>>>> What do I do next?
>>>> If you want to modify the URL, you'll need to use mod_proxy. Then you
>>>> can do:
>>>>
>>>> ProxyPass /tomcat7 http://localhost:8080
>>>> or
>>>> ProxyPass /tomcat7 ajp://localhost:8080
>>>>
>>>> Note that as soon as you start modifying the URL as part of the
>>>> ProxyPass you open up a world of opportunity for things to go wrong
>>>> (redirects, cookie paths, links). All of these are fixable but it is a
>>>> lot easier just to use the same URL structure in both httpd and Tomcat.
>>>>
>>>> Mark
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
>>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 



Re: URI mapping

Posted by Eldon Olmstead <el...@ns.sympatico.ca>.

On 2011-10-22 5:57 PM, Pid wrote:
> On 22/10/2011 17:42, Eldon Olmstead wrote:
>> Thanks for the response Mark,
>>
>> Ok so if I want to keep mod_jk as part of this, ( it is what we use at
>> work ), then if I understand right, I have no choice but to make tomcat
>> support /tomcat7/ in the path. Do I do this just by moving all the
>> webapps under webapps/tomcat7/?
> No.  The appBase (the 'webapps' dir in your case) is not a document root
> like HTTPD, it is the location for your apps - their published paths are
> based on their names (usually).
>
> You would have rename the applications, from:
>
>   tomcat/webapps/app1.war         - http://host/app1
>   tomcat/webapps/app2.war         - http://host/app2
>
> to:
>
>   tomcat/webapps/tomcat7#app1.war - http://host/tomcat7/app1
>   tomcat/webapps/tomcat7#app2.war - http://host/tomcat7/app2
>
> The '#' in the name is translated to a '/' in the path.
OK, so what about the folders that come with Tomcat then? Like ROOT, 
manager, and host-manager? Do I jar those up and name them as 
tomcat7#ROOT.war, tomcat7#manager.war, and tomcat7#host-manager.war?

I just tried creating wars for the above but that doesn't work.

Tomcat's access log is showing apache is passing on the request:
127.0.0.1 - - [22/Oct/2011:18:27:06 -0300] "GET /tomcat7 HTTP/1.1" 404 -
127.0.0.1 - - [22/Oct/2011:18:27:14 -0300] "GET /tomcat7/ROOT HTTP/1.1" 
404 -  ( tried this just in case )
127.0.0.1 - - [22/Oct/2011:18:27:21 -0300] "GET /tomcat7/manager 
HTTP/1.1" 404 -

The apps aren't being found.
>
>
> p
>
>> Will I have to make other configuration changes?
>>
>> What is the right way to do this? The way we have it at work is that
>> each tomcat worker is pointing to one developer's tomcat installation
>> for the developer to do with as they need.
>>
>> On 2011-10-22 1:17 PM, Mark Thomas wrote:
>>> On 22/10/2011 17:11, Eldon Olmstead wrote:
>>>> Hello,
>>>>
>>>> I'm using the following
>>>> Apache2.2
>>>> mod_jk 1.2.32
>>>> Tomcat 7.0.21
>>>>
>>>> I am trying to understand how to configure Apache to allow access to
>>>> Tomcat via mod_jk. I have already made some progress, but have got stuck
>>>> on one point.
>>>>
>>>> Currently, I can access Apache at http://localhost ( works )
>>>> I can also access tomcats default wepapp and the manager and
>>>> host-manager via
>>>>
>>>> http://localhost:8080/
>>>> http://localhost:8080/manager
>>>> http://localhost:8080/host-manager
>>>>
>>>>
>>>> What I want to do next it to connect Apache to Tomcat via mod_jk such
>>>> that the following URLs work
>>>>
>>>> http://localhost/tomcat7/ ( default tomcat webapp)
>>>> http://localhost/tomcat7/manager
>>>> http://localhost/tomcat7/host-manager
>>>>
>>>>
>>>> I have updated the workers.properties with:
>>>>
>>>>      worker.list=tomcat7
>>>>      worker.tomcat7.type=ajp13
>>>>      worker.tomcat7.host=localhost
>>>>      worker.tomcat7.port=8809
>>>>
>>>> I have added the the following in my http-jk.conf that I include in
>>>> http.conf:
>>>>
>>>>      JkMount  /tomcat7/* tomcat7
>>>>
>>>> When I try to access http://localhost/tomcat7, tomcat is given the URI
>>>> /tomcat7/
>>>>
>>>>      127.0.0.1 - - [22/Oct/2011:11:34:20 -0300] "GET /tomcat7/ HTTP/1.1"
>>>>      404 979
>>>>
>>>> So from the above log, I know that apache is forwarding the requests to
>>>> tomcat via mod_jk ok, but tomcat now thinks that /tomcat7/ is now part
>>>> of the request and since there is no tomcat7 web app, it doesn't match
>>>> the request.
>>>>
>>>> I would like http://localhost/tomcat7/ to map to the root of my Tomcat,
>>>> and to be able to access http://localhost/tomcat7/manager,
>>>> http://localhost/tomcat7/host-manager.
>>>>
>>>> What do I do next?
>>> If you want to modify the URL, you'll need to use mod_proxy. Then you
>>> can do:
>>>
>>> ProxyPass /tomcat7 http://localhost:8080
>>> or
>>> ProxyPass /tomcat7 ajp://localhost:8080
>>>
>>> Note that as soon as you start modifying the URL as part of the
>>> ProxyPass you open up a world of opportunity for things to go wrong
>>> (redirects, cookie paths, links). All of these are fixable but it is a
>>> lot easier just to use the same URL structure in both httpd and Tomcat.
>>>
>>> Mark
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>

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


Re: URI mapping

Posted by Pid <pi...@pidster.com>.
On 22/10/2011 17:42, Eldon Olmstead wrote:
> Thanks for the response Mark,
> 
> Ok so if I want to keep mod_jk as part of this, ( it is what we use at
> work ), then if I understand right, I have no choice but to make tomcat
> support /tomcat7/ in the path. Do I do this just by moving all the
> webapps under webapps/tomcat7/? 

No.  The appBase (the 'webapps' dir in your case) is not a document root
like HTTPD, it is the location for your apps - their published paths are
based on their names (usually).

You would have rename the applications, from:

 tomcat/webapps/app1.war         - http://host/app1
 tomcat/webapps/app2.war         - http://host/app2

to:

 tomcat/webapps/tomcat7#app1.war - http://host/tomcat7/app1
 tomcat/webapps/tomcat7#app2.war - http://host/tomcat7/app2

The '#' in the name is translated to a '/' in the path.


p

> Will I have to make other configuration changes?
> 
> What is the right way to do this? The way we have it at work is that
> each tomcat worker is pointing to one developer's tomcat installation
> for the developer to do with as they need.
> 
> On 2011-10-22 1:17 PM, Mark Thomas wrote:
>> On 22/10/2011 17:11, Eldon Olmstead wrote:
>>> Hello,
>>>
>>> I'm using the following
>>> Apache2.2
>>> mod_jk 1.2.32
>>> Tomcat 7.0.21
>>>
>>> I am trying to understand how to configure Apache to allow access to
>>> Tomcat via mod_jk. I have already made some progress, but have got stuck
>>> on one point.
>>>
>>> Currently, I can access Apache at http://localhost ( works )
>>> I can also access tomcats default wepapp and the manager and
>>> host-manager via
>>>
>>> http://localhost:8080/
>>> http://localhost:8080/manager
>>> http://localhost:8080/host-manager
>>>
>>>
>>> What I want to do next it to connect Apache to Tomcat via mod_jk such
>>> that the following URLs work
>>>
>>> http://localhost/tomcat7/ ( default tomcat webapp)
>>> http://localhost/tomcat7/manager
>>> http://localhost/tomcat7/host-manager
>>>
>>>
>>> I have updated the workers.properties with:
>>>
>>>     worker.list=tomcat7
>>>     worker.tomcat7.type=ajp13
>>>     worker.tomcat7.host=localhost
>>>     worker.tomcat7.port=8809
>>>
>>> I have added the the following in my http-jk.conf that I include in
>>> http.conf:
>>>
>>>     JkMount  /tomcat7/* tomcat7
>>>
>>> When I try to access http://localhost/tomcat7, tomcat is given the URI
>>> /tomcat7/
>>>
>>>     127.0.0.1 - - [22/Oct/2011:11:34:20 -0300] "GET /tomcat7/ HTTP/1.1"
>>>     404 979
>>>
>>> So from the above log, I know that apache is forwarding the requests to
>>> tomcat via mod_jk ok, but tomcat now thinks that /tomcat7/ is now part
>>> of the request and since there is no tomcat7 web app, it doesn't match
>>> the request.
>>>
>>> I would like http://localhost/tomcat7/ to map to the root of my Tomcat,
>>> and to be able to access http://localhost/tomcat7/manager,
>>> http://localhost/tomcat7/host-manager.
>>>
>>> What do I do next?
>> If you want to modify the URL, you'll need to use mod_proxy. Then you
>> can do:
>>
>> ProxyPass /tomcat7 http://localhost:8080
>> or
>> ProxyPass /tomcat7 ajp://localhost:8080
>>
>> Note that as soon as you start modifying the URL as part of the
>> ProxyPass you open up a world of opportunity for things to go wrong
>> (redirects, cookie paths, links). All of these are fixable but it is a
>> lot easier just to use the same URL structure in both httpd and Tomcat.
>>
>> Mark
>>
>> ---------------------------------------------------------------------
>> 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: URI mapping

Posted by Eldon Olmstead <el...@ns.sympatico.ca>.
Thanks for the response Mark,

Ok so if I want to keep mod_jk as part of this, ( it is what we use at 
work ), then if I understand right, I have no choice but to make tomcat 
support /tomcat7/ in the path. Do I do this just by moving all the 
webapps under webapps/tomcat7/? Will I have to make other configuration 
changes?

What is the right way to do this? The way we have it at work is that 
each tomcat worker is pointing to one developer's tomcat installation 
for the developer to do with as they need.

On 2011-10-22 1:17 PM, Mark Thomas wrote:
> On 22/10/2011 17:11, Eldon Olmstead wrote:
>> Hello,
>>
>> I'm using the following
>> Apache2.2
>> mod_jk 1.2.32
>> Tomcat 7.0.21
>>
>> I am trying to understand how to configure Apache to allow access to
>> Tomcat via mod_jk. I have already made some progress, but have got stuck
>> on one point.
>>
>> Currently, I can access Apache at http://localhost ( works )
>> I can also access tomcats default wepapp and the manager and
>> host-manager via
>>
>> http://localhost:8080/
>> http://localhost:8080/manager
>> http://localhost:8080/host-manager
>>
>>
>> What I want to do next it to connect Apache to Tomcat via mod_jk such
>> that the following URLs work
>>
>> http://localhost/tomcat7/ ( default tomcat webapp)
>> http://localhost/tomcat7/manager
>> http://localhost/tomcat7/host-manager
>>
>>
>> I have updated the workers.properties with:
>>
>>     worker.list=tomcat7
>>     worker.tomcat7.type=ajp13
>>     worker.tomcat7.host=localhost
>>     worker.tomcat7.port=8809
>>
>> I have added the the following in my http-jk.conf that I include in
>> http.conf:
>>
>>     JkMount  /tomcat7/* tomcat7
>>
>> When I try to access http://localhost/tomcat7, tomcat is given the URI
>> /tomcat7/
>>
>>     127.0.0.1 - - [22/Oct/2011:11:34:20 -0300] "GET /tomcat7/ HTTP/1.1"
>>     404 979
>>
>> So from the above log, I know that apache is forwarding the requests to
>> tomcat via mod_jk ok, but tomcat now thinks that /tomcat7/ is now part
>> of the request and since there is no tomcat7 web app, it doesn't match
>> the request.
>>
>> I would like http://localhost/tomcat7/ to map to the root of my Tomcat,
>> and to be able to access http://localhost/tomcat7/manager,
>> http://localhost/tomcat7/host-manager.
>>
>> What do I do next?
> If you want to modify the URL, you'll need to use mod_proxy. Then you
> can do:
>
> ProxyPass /tomcat7 http://localhost:8080
> or
> ProxyPass /tomcat7 ajp://localhost:8080
>
> Note that as soon as you start modifying the URL as part of the
> ProxyPass you open up a world of opportunity for things to go wrong
> (redirects, cookie paths, links). All of these are fixable but it is a
> lot easier just to use the same URL structure in both httpd and Tomcat.
>
> Mark
>
> ---------------------------------------------------------------------
> 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: URI mapping

Posted by Tobias Crefeld <tc...@cataneo.eu>.
Am Sat, 22 Oct 2011 17:17:26 +0100 schrieb Mark Thomas
<ma...@apache.org>:

> ProxyPass /tomcat7 http://localhost:8080
> or
> ProxyPass /tomcat7 ajp://localhost:8080

Usually Tomcat is listening for ajp-requests on port 8009, not 8080.

Regards,
 Tobias.

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


Re: URI mapping

Posted by Mark Thomas <ma...@apache.org>.
On 22/10/2011 17:11, Eldon Olmstead wrote:
> Hello,
> 
> I'm using the following
> Apache2.2
> mod_jk 1.2.32
> Tomcat 7.0.21
> 
> I am trying to understand how to configure Apache to allow access to
> Tomcat via mod_jk. I have already made some progress, but have got stuck
> on one point.
> 
> Currently, I can access Apache at http://localhost ( works )
> I can also access tomcats default wepapp and the manager and
> host-manager via
> 
> http://localhost:8080/
> http://localhost:8080/manager
> http://localhost:8080/host-manager
> 
> 
> What I want to do next it to connect Apache to Tomcat via mod_jk such
> that the following URLs work
> 
> http://localhost/tomcat7/ ( default tomcat webapp)
> http://localhost/tomcat7/manager
> http://localhost/tomcat7/host-manager
> 
> 
> I have updated the workers.properties with:
> 
>    worker.list=tomcat7
>    worker.tomcat7.type=ajp13
>    worker.tomcat7.host=localhost
>    worker.tomcat7.port=8809
> 
> I have added the the following in my http-jk.conf that I include in
> http.conf:
> 
>    JkMount  /tomcat7/* tomcat7
> 
> When I try to access http://localhost/tomcat7, tomcat is given the URI
> /tomcat7/
> 
>    127.0.0.1 - - [22/Oct/2011:11:34:20 -0300] "GET /tomcat7/ HTTP/1.1"
>    404 979
> 
> So from the above log, I know that apache is forwarding the requests to
> tomcat via mod_jk ok, but tomcat now thinks that /tomcat7/ is now part
> of the request and since there is no tomcat7 web app, it doesn't match
> the request.
> 
> I would like http://localhost/tomcat7/ to map to the root of my Tomcat,
> and to be able to access http://localhost/tomcat7/manager,
> http://localhost/tomcat7/host-manager.
> 
> What do I do next?

If you want to modify the URL, you'll need to use mod_proxy. Then you
can do:

ProxyPass /tomcat7 http://localhost:8080
or
ProxyPass /tomcat7 ajp://localhost:8080

Note that as soon as you start modifying the URL as part of the
ProxyPass you open up a world of opportunity for things to go wrong
(redirects, cookie paths, links). All of these are fixable but it is a
lot easier just to use the same URL structure in both httpd and Tomcat.

Mark

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