You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Bithost Ltda." <bi...@gmail.com> on 2010/05/26 23:32:51 UTC
apache 2 + tomcat 6 virtualhost question
Hello
I'm new to tomcat and i have some experience with apache, i have a
debian server with apache 2.2 + mod_jk and tomcat 6 server.
My doc root for my site is /home/mydomain/htdocs and i have a site which
is using a WAR which i deployed it via the tomcat manager.
So far if i go to http://mydomain:8080/myapp it shows fine, but now what
i need is that if i type www.mydomain.com it has to show the app
directly. I've managed to create an htaccess with a 301 redirect to the
url http://mydomain:8080/myapp as a temporal fix, but what i need is
that when i type www.mydomain.com it goes to my app and stays with the
mydomain.com url.
How can i do that? do you need any config file? any help is appreciated.
Thanks in advance.
--
Patricio López Salgado
Jefe de Operaciones
2-697 9216
<http://www.bithost.cl>
Re: apache 2 + tomcat 6 virtualhost question
Posted by "Bithost Ltda." <bi...@gmail.com>.
El 26-05-10 23:11, Caldarale, Charles R escribió:
>> From: Bithost Ltda. [mailto:bithost.chile@gmail.com]
>> Subject: Re: apache 2 + tomcat 6 virtualhost question
>>
>> Well it seems that such is for only one domain, and i will be deploying
>> more than one, thats why i cant use ROOT
>>
> Then declare multiple<Host> elements in Tomcat, each with its own appBase setting, and using ROOT as the default webapp for each. The doc is here:
> http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html
>
> And some getting started examples for the above:
> http://wiki.apache.org/tomcat/TomcatDevelopmentVirtualHosts
>
> Are you using httpd for something other than routing traffic to Tomcat (e.g., running PHP)? If not, why do you have it?
>
> - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
Yes I do host other php sites which do not use/have any java app, thats
why i still need apache.
--
Patricio López Salgado
Jefe de Operaciones
2-697 9216
<http://www.bithost.cl>
Re: apache 2 + tomcat 6 virtualhost question
Posted by Rainer Jung <ra...@kippdata.de>.
On 27.05.2010 05:11, Caldarale, Charles R wrote:
>> From: Bithost Ltda. [mailto:bithost.chile@gmail.com]
>> Subject: Re: apache 2 + tomcat 6 virtualhost question
>>
>> Well it seems that such is for only one domain, and i will be deploying
>> more than one, thats why i cant use ROOT
>
> Then declare multiple<Host> elements in Tomcat, each with its own appBase setting, and using ROOT as the default webapp for each. The doc is here:
> http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html
>
> And some getting started examples for the above:
> http://wiki.apache.org/tomcat/TomcatDevelopmentVirtualHosts
>
> Are you using httpd for something other than routing traffic to Tomcat (e.g., running PHP)? If not, why do you have it?
I would also suggest:
- try Tomcat virtual Hosts and a ROOT context per host
- if this doesn't work for you for some good reason, rewriting URLs is
easier with mod_proxy than with mod_jk. It is one of the few areas,
where mod_jk lags.
- if you still want to use mod_jk, because it has other benefits, read
about the solution on
http://tomcat.apache.org/connectors-doc/generic_howto/proxy.html#URL%20Handling
The rest of the page might be interesting for you too.
Regards,
Rainer
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: apache 2 + tomcat 6 virtualhost question
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Bithost Ltda. [mailto:bithost.chile@gmail.com]
> Subject: Re: apache 2 + tomcat 6 virtualhost question
>
> Well it seems that such is for only one domain, and i will be deploying
> more than one, thats why i cant use ROOT
Then declare multiple <Host> elements in Tomcat, each with its own appBase setting, and using ROOT as the default webapp for each. The doc is here:
http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html
And some getting started examples for the above:
http://wiki.apache.org/tomcat/TomcatDevelopmentVirtualHosts
Are you using httpd for something other than routing traffic to Tomcat (e.g., running PHP)? If not, why do you have it?
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: apache 2 + tomcat 6 virtualhost question
Posted by "Bithost Ltda." <bi...@gmail.com>.
El 26-05-10 17:39, Caldarale, Charles R escribió:
>> From: Bithost Ltda. [mailto:bithost.chile@gmail.com]
>> Subject: apache 2 + tomcat 6 virtualhost question
>>
>> what i need is that when i type www.mydomain.com it goes
>> to my app and stays with the mydomain.com url.
>>
> The Tomcat side of the configuration is covered in the FAQ:
> http://wiki.apache.org/tomcat/HowTo#How_do_I_make_my_web_application_be_the_Tomcat_default_application_.3F
>
> Not sure what you have to do with httpd, if anything (other than remove your redirect).
>
> - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
Well it seems that such is for only one domain, and i will be deploying
more than one, thats why i cant use ROOT so i hope any1 can help me a
bit further. Thanks.
--
Patricio López Salgado
Jefe de Operaciones
2-697 9216
<http://www.bithost.cl>
RE: apache 2 + tomcat 6 virtualhost question
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Bithost Ltda. [mailto:bithost.chile@gmail.com]
> Subject: apache 2 + tomcat 6 virtualhost question
>
> what i need is that when i type www.mydomain.com it goes
> to my app and stays with the mydomain.com url.
The Tomcat side of the configuration is covered in the FAQ:
http://wiki.apache.org/tomcat/HowTo#How_do_I_make_my_web_application_be_the_Tomcat_default_application_.3F
Not sure what you have to do with httpd, if anything (other than remove your redirect).
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: apache 2 + tomcat 6 virtualhost question
Posted by Borut Hadžialić <bo...@gmail.com>.
In that case you can have one tomcat instance per application. Each
application can run inside its own tomcat process and have different
ajp port, mod_jk worker and apache virtual host.
On Thu, May 27, 2010 at 1:29 AM, Bithost Ltda. <bi...@gmail.com> wrote:
> El 26-05-10 18:31, Borut Hadžialić escribió:
>>
>> Hi Patricio, try this:
>>
>> 1. Redeploy your app in tomcat so it shows at http://mydomain:8080/
>> instead of http://mydomain:8080/myapp
>>
>> How you do this depends on how you deployed the app in the first place -
>>
>> a) if you deployed a myapp.war and use autodeploy, then rename it to
>> ROOT.war and redeploy it
>> b) if you are using a <Context element, set its path attribute to ""
>>
>> 2. Add an AJP connector to your tomcat's conf/server.xml eg:
>> <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"
>> URIEncoding="utf8"/>
>> and restart tomcat
>>
>> 3. Define an apache mod_jk worker eg:
>> /usr/local/apache2/conf/workers.properties:
>>
>> worker.list=myapp
>>
>> worker.myapp.type=ajp13
>> worker.myapp.host=localhost
>> worker.myapp.port=8109
>>
>> 4. Add a virtual host in apache configuration:
>>
>> NameVirtualHost *:80
>> ....
>>
>> <VirtualHost *:80>
>> ServerAdmin you@gmail.com <ma...@gmail.com>
>> DocumentRoot "/usr/local/apache2/htdocs" <--- this is irrelevant
>> because of JkMount /*
>> ServerName www.mydomain.com <http://www.mydomain.com>
>> # ServerAlias www.somethingelse.com <http://www.somethingelse.com>
>> ErrorLog "logs/www.mydomain.com-error_log"
>> CustomLog "logs/www.mydomain.com-access_log" common#
>> JkMount /* myapp
>> </VirtualHost>
>>
>> 5. Make sure mod_jk config is in apache conf:
>> <IfModule jk_module>
>> JkWorkersFile /usr/local/apache2/conf/workers.properties
>> JkShmFile /usr/local/apache2/logs/mod_jk.shm
>> JkLogFile /usr/local/apache2/logs/mod_jk.log
>> JkLogLevel info
>> JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
>> </IfModule>
>>
>> Restart apache.
>>
>> In that case files in /home/mydomain/htdocs are no longer relevant.
>>
>>
>>
>> On Wed, May 26, 2010 at 11:32 PM, Bithost Ltda. <bithost.chile@gmail.com
>> <ma...@gmail.com>> wrote:
>>
>> Hello
>>
>> I'm new to tomcat and i have some experience with apache, i have a
>> debian server with apache 2.2 + mod_jk and tomcat 6 server.
>> My doc root for my site is /home/mydomain/htdocs and i have a site
>> which is using a WAR which i deployed it via the tomcat manager.
>> So far if i go to http://mydomain:8080/myapp it shows fine, but
>> now what i need is that if i type www.mydomain.com
>> <http://www.mydomain.com> it has to show the app directly. I've
>> managed to create an htaccess with a 301 redirect to the url
>> http://mydomain:8080/myapp as a temporal fix, but what i need is
>> that when i type www.mydomain.com <http://www.mydomain.com> it
>> goes to my app and stays with the mydomain.com
>> <http://mydomain.com> url.
>> How can i do that? do you need any config file? any help is
>> appreciated.
>>
>> Thanks in advance.
>>
>>
>> -- Patricio López Salgado
>> Jefe de Operaciones
>> 2-697 9216
>>
>> <http://www.bithost.cl>
>>
>>
>>
>>
>> --
>> Why?
>> Because YES!
>
> Hello
>
> I appreciate this very helpful guide, i have some of these configs already
> in motion (got the ajp connector port, workers.properties and mod_jk
> included in apache), but what if i have more than 2 sites which need the
> same way of deploy (virtualhosting), in that case i can't deploy it under
> mydomain.com:8080, it has to be under mydomain.com:8080/myapp
> Thanks for your time.
>
--
Why?
Because YES!
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: apache 2 + tomcat 6 virtualhost question
Posted by Hassan Schroeder <ha...@gmail.com>.
On Wed, May 26, 2010 at 4:29 PM, Bithost Ltda. <bi...@gmail.com> wrote:
> I appreciate this very helpful guide, i have some of these configs already
> in motion (got the ajp connector port, workers.properties and mod_jk
> included in apache), but what if i have more than 2 sites which need the
> same way of deploy (virtualhosting), in that case i can't deploy it under
> mydomain.com:8080, it has to be under mydomain.com:8080/myapp
Frankly, I wouldn't do any of the above.
Set up your Tomcat for named virtual hosting and use mod_proxy
on the httpd to forward requests for those hosts, i.e. anything that
isn't being served direct from httpd.
Much, much simpler. :-)
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: apache 2 + tomcat 6 virtualhost question
Posted by "Bithost Ltda." <bi...@gmail.com>.
El 26-05-10 18:31, Borut Hadžialić escribió:
> Hi Patricio, try this:
>
> 1. Redeploy your app in tomcat so it shows at http://mydomain:8080/
> instead of http://mydomain:8080/myapp
>
> How you do this depends on how you deployed the app in the first place -
>
> a) if you deployed a myapp.war and use autodeploy, then rename it to
> ROOT.war and redeploy it
> b) if you are using a <Context element, set its path attribute to ""
>
> 2. Add an AJP connector to your tomcat's conf/server.xml eg:
> <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"
> URIEncoding="utf8"/>
> and restart tomcat
>
> 3. Define an apache mod_jk worker eg:
> /usr/local/apache2/conf/workers.properties:
>
> worker.list=myapp
>
> worker.myapp.type=ajp13
> worker.myapp.host=localhost
> worker.myapp.port=8109
>
> 4. Add a virtual host in apache configuration:
>
> NameVirtualHost *:80
> ....
>
> <VirtualHost *:80>
> ServerAdmin you@gmail.com <ma...@gmail.com>
> DocumentRoot "/usr/local/apache2/htdocs" <--- this is irrelevant
> because of JkMount /*
> ServerName www.mydomain.com <http://www.mydomain.com>
> # ServerAlias www.somethingelse.com <http://www.somethingelse.com>
> ErrorLog "logs/www.mydomain.com-error_log"
> CustomLog "logs/www.mydomain.com-access_log" common#
> JkMount /* myapp
> </VirtualHost>
>
> 5. Make sure mod_jk config is in apache conf:
> <IfModule jk_module>
> JkWorkersFile /usr/local/apache2/conf/workers.properties
> JkShmFile /usr/local/apache2/logs/mod_jk.shm
> JkLogFile /usr/local/apache2/logs/mod_jk.log
> JkLogLevel info
> JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
> </IfModule>
>
> Restart apache.
>
> In that case files in /home/mydomain/htdocs are no longer relevant.
>
>
>
> On Wed, May 26, 2010 at 11:32 PM, Bithost Ltda.
> <bithost.chile@gmail.com <ma...@gmail.com>> wrote:
>
> Hello
>
> I'm new to tomcat and i have some experience with apache, i have a
> debian server with apache 2.2 + mod_jk and tomcat 6 server.
> My doc root for my site is /home/mydomain/htdocs and i have a site
> which is using a WAR which i deployed it via the tomcat manager.
> So far if i go to http://mydomain:8080/myapp it shows fine, but
> now what i need is that if i type www.mydomain.com
> <http://www.mydomain.com> it has to show the app directly. I've
> managed to create an htaccess with a 301 redirect to the url
> http://mydomain:8080/myapp as a temporal fix, but what i need is
> that when i type www.mydomain.com <http://www.mydomain.com> it
> goes to my app and stays with the mydomain.com
> <http://mydomain.com> url.
> How can i do that? do you need any config file? any help is
> appreciated.
>
> Thanks in advance.
>
>
> --
> Patricio López Salgado
> Jefe de Operaciones
> 2-697 9216
>
> <http://www.bithost.cl>
>
>
>
>
> --
> Why?
> Because YES!
Hello
I appreciate this very helpful guide, i have some of these configs
already in motion (got the ajp connector port, workers.properties and
mod_jk included in apache), but what if i have more than 2 sites which
need the same way of deploy (virtualhosting), in that case i can't
deploy it under mydomain.com:8080, it has to be under
mydomain.com:8080/myapp
Thanks for your time.
Re: apache 2 + tomcat 6 virtualhost question
Posted by Borut Hadžialić <bo...@gmail.com>.
Small mistake - put
worker.myapp.port=8009 instead of worker.myapp.port=8109 (port needs to be
the same as the one in tomcat's conf/server.xml <Connector port="8009"
protocol="AJP/1.3" .. )
On Thu, May 27, 2010 at 12:31 AM, Borut Hadžialić <borut.hadzialic@gmail.com
> wrote:
> Hi Patricio, try this:
>
> 1. Redeploy your app in tomcat so it shows at http://mydomain:8080/instead of
> http://mydomain:8080/myapp
>
> How you do this depends on how you deployed the app in the first place -
>
> a) if you deployed a myapp.war and use autodeploy, then rename it to
> ROOT.war and redeploy it
> b) if you are using a <Context element, set its path attribute to ""
>
> 2. Add an AJP connector to your tomcat's conf/server.xml eg:
> <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"
> URIEncoding="utf8"/>
> and restart tomcat
>
> 3. Define an apache mod_jk worker eg:
> /usr/local/apache2/conf/workers.properties:
>
> worker.list=myapp
>
> worker.myapp.type=ajp13
> worker.myapp.host=localhost
> worker.myapp.port=8109
>
> 4. Add a virtual host in apache configuration:
>
> NameVirtualHost *:80
> ....
>
> <VirtualHost *:80>
> ServerAdmin you@gmail.com
> DocumentRoot "/usr/local/apache2/htdocs" <--- this is irrelevant
> because of JkMount /*
> ServerName www.mydomain.com
> # ServerAlias www.somethingelse.com
> ErrorLog "logs/www.mydomain.com-error_log"
> CustomLog "logs/www.mydomain.com-access_log" common#
> JkMount /* myapp
> </VirtualHost>
>
> 5. Make sure mod_jk config is in apache conf:
> <IfModule jk_module>
> JkWorkersFile /usr/local/apache2/conf/workers.properties
> JkShmFile /usr/local/apache2/logs/mod_jk.shm
> JkLogFile /usr/local/apache2/logs/mod_jk.log
> JkLogLevel info
> JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
> </IfModule>
>
> Restart apache.
>
> In that case files in /home/mydomain/htdocs are no longer relevant.
>
>
>
>
> On Wed, May 26, 2010 at 11:32 PM, Bithost Ltda. <bi...@gmail.com>wrote:
>
>> Hello
>>
>> I'm new to tomcat and i have some experience with apache, i have a debian
>> server with apache 2.2 + mod_jk and tomcat 6 server.
>> My doc root for my site is /home/mydomain/htdocs and i have a site which
>> is using a WAR which i deployed it via the tomcat manager.
>> So far if i go to http://mydomain:8080/myapp it shows fine, but now what
>> i need is that if i type www.mydomain.com it has to show the app
>> directly. I've managed to create an htaccess with a 301 redirect to the url
>> http://mydomain:8080/myapp as a temporal fix, but what i need is that
>> when i type www.mydomain.com it goes to my app and stays with the
>> mydomain.com url.
>> How can i do that? do you need any config file? any help is appreciated.
>>
>> Thanks in advance.
>>
>>
>> --
>> Patricio López Salgado
>> Jefe de Operaciones
>> 2-697 9216
>>
>> <http://www.bithost.cl>
>>
>
>
>
> --
> Why?
> Because YES!
>
--
Why?
Because YES!
Re: apache 2 + tomcat 6 virtualhost question
Posted by Borut Hadžialić <bo...@gmail.com>.
Hi Patricio, try this:
1. Redeploy your app in tomcat so it shows at http://mydomain:8080/ instead
of http://mydomain:8080/myapp
How you do this depends on how you deployed the app in the first place -
a) if you deployed a myapp.war and use autodeploy, then rename it to
ROOT.war and redeploy it
b) if you are using a <Context element, set its path attribute to ""
2. Add an AJP connector to your tomcat's conf/server.xml eg:
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443"
URIEncoding="utf8"/>
and restart tomcat
3. Define an apache mod_jk worker eg:
/usr/local/apache2/conf/workers.properties:
worker.list=myapp
worker.myapp.type=ajp13
worker.myapp.host=localhost
worker.myapp.port=8109
4. Add a virtual host in apache configuration:
NameVirtualHost *:80
....
<VirtualHost *:80>
ServerAdmin you@gmail.com
DocumentRoot "/usr/local/apache2/htdocs" <--- this is irrelevant
because of JkMount /*
ServerName www.mydomain.com
# ServerAlias www.somethingelse.com
ErrorLog "logs/www.mydomain.com-error_log"
CustomLog "logs/www.mydomain.com-access_log" common#
JkMount /* myapp
</VirtualHost>
5. Make sure mod_jk config is in apache conf:
<IfModule jk_module>
JkWorkersFile /usr/local/apache2/conf/workers.properties
JkShmFile /usr/local/apache2/logs/mod_jk.shm
JkLogFile /usr/local/apache2/logs/mod_jk.log
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
</IfModule>
Restart apache.
In that case files in /home/mydomain/htdocs are no longer relevant.
On Wed, May 26, 2010 at 11:32 PM, Bithost Ltda. <bi...@gmail.com>wrote:
> Hello
>
> I'm new to tomcat and i have some experience with apache, i have a debian
> server with apache 2.2 + mod_jk and tomcat 6 server.
> My doc root for my site is /home/mydomain/htdocs and i have a site which is
> using a WAR which i deployed it via the tomcat manager.
> So far if i go to http://mydomain:8080/myapp it shows fine, but now what i
> need is that if i type www.mydomain.com it has to show the app directly.
> I've managed to create an htaccess with a 301 redirect to the url
> http://mydomain:8080/myapp as a temporal fix, but what i need is that when
> i type www.mydomain.com it goes to my app and stays with the mydomain.comurl.
> How can i do that? do you need any config file? any help is appreciated.
>
> Thanks in advance.
>
>
> --
> Patricio López Salgado
> Jefe de Operaciones
> 2-697 9216
>
> <http://www.bithost.cl>
>
--
Why?
Because YES!