Re: Serve same content to multiple URL's

2013-04-05 Thread André Warnier

Chris Arnold wrote:

I didn't think I needed a second worker but because the working
config only worked for http://share.domain1.com and nothing else, I
wanted to verify it should work or I needed another worker and you
verified I do not need another worker and in fact, the existing
config for http://share.domain1.com should work for
http://share.domain2.com



You definitely don't need a second worker.


Great! I know i am going in the right direction


Why do you need a second VirtualHost, even?

Apache has to answer for that request (http://share.domain2.com)
and pass it to tomcat




Maybe some basic information to clear up things in the first place :

When you work with virtual hosts, as well under Apache httpd as under Tomcat, the basic 
principle is this :


When the server receives the request, it examines the request to determine to which 
hostname it is addressed.
The server then cycles through all the hosts in its configuration, to find one whose 
declared hostname matches the hostname contained in the request.
If it finds one that matches (either on the declared hostname or a declared alias), it 
loads the configuration of that one, to process this request.
If it does not find a declared host that matches, then it defaults to its default host 
to process this request.


Both Apache httpd and Tomcat have a default host, but the way in which this is 
configured is different in each.


- for Tomcat, it is the host which is declared in the Engine tag of rhe server.xml 
file. Usually, this is :

Engine name=Catalina defaultHost=localhost
and later in the server.xml. you will find the corresponding Host tag, like :
Host name=localhost  ...

- for Apache httpd, there is no explicity defined default host, but the default host is 
the first declared VirtualHost (*) matching the port on which the request was received.

(*) from top to bottom of the configuration file, including all the includes)

So, assuming that all requests which are forwarded by Apache to Tomcat can be processed by 
the same webapp(s), then you do not need to define any virtual hosts in Tomcat (other than 
the standard default Host name=localhost, because :
when Tomcat receives the request, it will look at the host to which it is addressed, and 
try to match this with the hostname or alias of one of its Host's.  Since it will not 
find any, it will default to the Host name=localhost to process the request, and 
that's exactly what you want anyway.


It is the same within Apache httpd : if all you want is that your server accepts requests 
for hostname1.mycompany.com and hostname2.mycompany.com and processes them in exactly 
the same way, then all you would need to do is define one VirtualHost such that either 
the ServerName or a ServerAlias matches one of those names (or so that none matches, which 
would cause the request to be processed by the default host).
You /can/ define 2 VirtualHost's, each with the appropriate ServerName, but you don't 
really have to do that unless you really want some things to happen differently in each.


(which in reality, is likely to happen sooner or later, so maybe you want to bite the 
bullet now anyway. But that's your choice).



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



Re: Serve same content to multiple URL's

2013-04-04 Thread Chris Arnold
- Original Message -
From: Chris Arnold carn...@electrichendrix.com
To: Tomcat Users List users@tomcat.apache.org
Sent: Thursday, April 4, 2013 12:28:02 PM
Subject: Serve same content to multiple URL's

I am not sure if this is a Tomcat issue or an apache issue, so i will ask on 
both lists.
We have tomcat 6.03 on SLES11 and have content/webapp that we want to server to 
multiple domains. We have 1 domain working using http://share.domain1.com. What 
we want is access to this same webapp using http://share.anydomain.com. Here 
are configuration files:

worker.properties:

worker.list=jk-status
worker.jk-status.type=status
worker.jk-status.read_only=true
worker.list=jk-manager
worker.list=worker1
worker.list=worker2
worker.jk-manager.type=status
worker.list=balancer
worker.balancer.type=lb
worker.balancer.max_reply_timeouts=10
worker.balancer.balance_workers=worker1
worker.worker1.reference=worker.template
worker.worker1.host=localhost
worker.worker1.port=8009
worker.worker1.activation=A
worker.balancer.balance_workers=worker2
worker.worker2.reference=worker.template
worker.worker2.host=localhost
worker.worker2.port=8009
worker.worker2.activation=A
worker.template.type=ajp13
worker.template.socket_keepalive=true
worker.template.connection_pool_minsize=0
worker.template.connection_pool_timeout=600
worker.template.reply_timeout=30
worker.template.recovery_options=3

Here is the configured virtualhost for that is working:
JkMount /share|/* worker1
RedirectMatch ^/$ http://share.domain.com/share/

I have tried to add a second worker (worker2) in workers.properties and added a 
virtualhost like:
Here is the configured virtualhost for domain2:
2nd virtualhost:
JkMount /share|/* worker2
RedirectMatch ^/$ http://share.domain2.com/share/

When i type http://share.domain2.com i arrive at 1 of our websites but not the 
tomcat content. When i type http://share.domain2.com/share i get a 404 error. 
Do i need to define another worker to accomplish this or should the defined 
worker work for any domain given there is a virtualhost defined?

I found the Tomcat virtualhost idea on a google search but not sure this is the 
optimum way to accomplish what we need to do? And i should mention the requests 
are first going to apache then forwarded to tomcat.

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



Re: Serve same content to multiple URL's

2013-04-04 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Chris,

On 4/4/13 12:28 PM, Chris Arnold wrote:
 I am not sure if this is a Tomcat issue or an apache issue, so i
 will ask on both lists.

While the solution might be in httpd, the Tomcat-user list is the
right place to ask about this kind of thing.

 We have tomcat 6.03 on SLES11 and have content/webapp that we want 
 to server to multiple domains. We have 1 domain working using 
 http://share.domain1.com. What we want is access to this same
 webapp using http://share.anydomain.com.

Generally speaking, you can let Tomcat (or even httpd) serve any
number of domain names identically by simply not using any
configuration that would lead to those virtual hosts being treated
differently.

 Here are configuration files:
 
 worker.properties:
 
 worker.list=jk-status worker.jk-status.type=status 
 worker.jk-status.read_only=true worker.list=jk-manager 
 worker.list=worker1 worker.list=worker2 
 worker.jk-manager.type=status worker.list=balancer 
 worker.balancer.type=lb worker.balancer.max_reply_timeouts=10 
 worker.balancer.balance_workers=worker1 
 worker.worker1.reference=worker.template 
 worker.worker1.host=localhost worker.worker1.port=8009 
 worker.worker1.activation=A 
 worker.balancer.balance_workers=worker2 
 worker.worker2.reference=worker.template 
 worker.worker2.host=localhost worker.worker2.port=8009 
 worker.worker2.activation=A worker.template.type=ajp13 
 worker.template.socket_keepalive=true 
 worker.template.connection_pool_minsize=0 
 worker.template.connection_pool_timeout=600 
 worker.template.reply_timeout=30 
 worker.template.recovery_options=3

Read-up on worker templates.

 Here is the configured virtualhost for that is working: JkMount
 /share|/* worker1 RedirectMatch ^/$ http://share.domain.com/share/
 
 I have tried to add a second worker (worker2) in workers.properties
 and added a virtualhost like: Here is the configured virtualhost
 for domain2: 2nd virtualhost: JkMount /share|/* worker2 
 RedirectMatch ^/$ http://share.domain2.com/share/

If you want the content to be identical, why do you need a second worker?

Why do you need a second VirtualHost, even?

 When i type http://share.domain2.com i arrive at 1 of our websites
  but not the tomcat content. When i type 
 http://share.domain2.com/share i get a 404 error. Do i need to
 define another worker to accomplish this or should the defined
 worker work for any domain given there is a virtualhost defined?

Workers don't care about VirtualHosts: the client's request headers
will be sent to Tomcat and another round of virtual host resolution
will occur over there. Having separate workers does not help anything.

I'm not sure why you are getting 404s: any idea if it's a response
coming from httpd or Tomcat? If you browse to
http://share.domain2.com/ are you properly redirected (as I would
expect given the above configuration) to http://share.domain2.com/share ?

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJRXclXAAoJEBzwKT+lPKRY1mYQAJz/KFXbtNaMYcpDymn94Krg
ENxqVUa/GwyPZf634M8o83E/kzqxE/g5hAxUnAi28YAnM4P3FQ0CsL09vZEJ4rpB
I33K8NLakR6HdGP+mt2otij9b6CVI62NvXI+TDWduoDDmvyHIoaYCW+36XcxPoVe
89H3LHDVE6BJ6NYh4nrmrJIzyfLNr6V0Z2A0gs39YOnknjAkxj1SdlZErNMqSvP9
V+HSGCawFU4h+dMXUzmffUWmdkWcImwMUx71za2ny2+9KeVdZreycXCJtN8m1LAE
WcBM4HTogQ29ZN/RRWtuOrkMKO2XF/5xc2GdrueQNatah6WzB6V0oN4OFy5/1dwi
G3ly45Mw2jdcqapoSUOrq61/7dEmnE4jDNWBQVAY2KnshjlHMdMWJD/VHxL9ROIQ
K/KlgPmgDFwzT3RRXENMt1cI4DEkjVDkiskwRNy4XWLX048TATSzZJftCvWXeBNJ
YgvsBCfXvpGJLWO+SVJcltprQGYy1FK4CnWiGEAy7Z2pseYZg4yTwmawpnxsOJsZ
bOQLLNJ/WCEh237/g0mH7Tp0ms2RlUa6Xe5Nd8Fa/zDKxYVUWODQY39P/lF8erD5
Prsd/pS1/+l7DIsPhaZO7DG9qfObGmsLWrBKulDtLewUJfza4X9OApJ3FIlKoL0v
3desveiO0MxcZ9ILBFSw
=4jO8
-END PGP SIGNATURE-

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



Re: Serve same content to multiple URL's

2013-04-04 Thread Chris Arnold
On Apr 4, 2013, at 2:38 PM, Christopher Schultz 
ch...@christopherschultz.net wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA256
 
 Chris,
 
 On 4/4/13 12:28 PM, Chris Arnold wrote:
 
 I have tried to add a second worker (worker2) in workers.properties
 and added a virtualhost like: Here is the configured virtualhost
 for domain2: 2nd virtualhost: JkMount /share|/* worker2 
 RedirectMatch ^/$ http://share.domain2.com/share/
 
 If you want the content to be identical, why do you need a second worker?

I didn't think I needed a second worker but because the working config only 
worked for http://share.domain1.com and nothing else, I wanted to verify it 
should work or I needed another worker and you verified I do not need another 
worker and in fact, the existing config for http://share.domain1.com should 
work for http://share.domain2.com
 
 Why do you need a second VirtualHost, even?

Apache has to answer for that request (http://share.domain2.com) and pass it to 
tomcat
 
 When i type http://share.domain2.com i arrive at 1 of our websites
 but not the tomcat content. When i type 
 http://share.domain2.com/share i get a 404 error. Do i need to
 define another worker to accomplish this or should the defined
 worker work for any domain given there is a virtualhost defined?
 
 Workers don't care about VirtualHosts: the client's request headers
 will be sent to Tomcat and another round of virtual host resolution
 will occur over there. Having separate workers does not help anything.
 
 I'm not sure why you are getting 404s: any idea if it's a response
 coming from httpd or Tomcat?

No error logs in apache or tomcat which is weird?

 If you browse to
 http://share.domain2.com/ are you properly redirected (as I would
 expect given the above configuration) to http://share.domain2.com/share ?

It doesn't appear so as a apache site answers the request. 

Re: Serve same content to multiple URL's

2013-04-04 Thread Igor Cicimov
On 05/04/2013 7:26 AM, Chris Arnold carn...@electrichendrix.com wrote:

 On Apr 4, 2013, at 2:38 PM, Christopher Schultz 
ch...@christopherschultz.net wrote:

  -BEGIN PGP SIGNED MESSAGE-
  Hash: SHA256
 
  Chris,
 
  On 4/4/13 12:28 PM, Chris Arnold wrote:
 
  I have tried to add a second worker (worker2) in workers.properties
  and added a virtualhost like: Here is the configured virtualhost
  for domain2: 2nd virtualhost: JkMount /share|/* worker2
  RedirectMatch ^/$ http://share.domain2.com/share/
 
  If you want the content to be identical, why do you need a second
worker?

 I didn't think I needed a second worker but because the working config
only worked for http://share.domain1.com and nothing else, I wanted to
verify it should work or I needed another worker and you verified I do not
need another worker and in fact, the existing config for
http://share.domain1.com should work for http://share.domain2.com
 
  Why do you need a second VirtualHost, even?

 Apache has to answer for that request (http://share.domain2.com) and pass
it to tomcat
 
You just need to create Alias in the existing VirtualHost in Apache and the
Host in Tomcat.

  When i type http://share.domain2.com i arrive at 1 of our websites
  but not the tomcat content. When i type
  http://share.domain2.com/share i get a 404 error. Do i need to
  define another worker to accomplish this or should the defined
  worker work for any domain given there is a virtualhost defined?
 
  Workers don't care about VirtualHosts: the client's request headers
  will be sent to Tomcat and another round of virtual host resolution
  will occur over there. Having separate workers does not help anything.
 
  I'm not sure why you are getting 404s: any idea if it's a response
  coming from httpd or Tomcat?

 No error logs in apache or tomcat which is weird?

  If you browse to
  http://share.domain2.com/ are you properly redirected (as I would
  expect given the above configuration) to http://share.domain2.com/share?

 It doesn't appear so as a apache site answers the request.


Re: Serve same content to multiple URL's

2013-04-04 Thread Chris Arnold
On Apr 4, 2013, at 4:45 PM, Igor Cicimov icici...@gmail.com wrote:

 You just need to create Alias in the existing VirtualHost in Apache and the
 Host in Tomcat.

So in the existing apache virtualhost, I need to make an alias entry? Like so:

VirtualHost *:80
   ServerName share.domain.com
   ServerAlias   share.domain2.com

  JkMount /share|/* worker1
  RedirectMatch http://share.domain.com/share
**i will need another redirectmatch here, wouldn't I? In order to redirect 
domain 2?
/VirtualHost

And in the tomcat server.xml, add a host entry?

Re: Serve same content to multiple URL's

2013-04-04 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Chris,

On 4/4/13 4:21 PM, Chris Arnold wrote:
 On Apr 4, 2013, at 2:38 PM, Christopher Schultz
 ch...@christopherschultz.net wrote:
 
 -BEGIN PGP SIGNED MESSAGE- Hash: SHA256
 
 Chris,
 
 On 4/4/13 12:28 PM, Chris Arnold wrote:
 
 I have tried to add a second worker (worker2) in
 workers.properties and added a virtualhost like: Here is the
 configured virtualhost for domain2: 2nd virtualhost: JkMount
 /share|/* worker2 RedirectMatch ^/$
 http://share.domain2.com/share/
 
 If you want the content to be identical, why do you need a second
 worker?
 
 I didn't think I needed a second worker but because the working
 config only worked for http://share.domain1.com and nothing else, I
 wanted to verify it should work or I needed another worker and you
 verified I do not need another worker and in fact, the existing
 config for http://share.domain1.com should work for
 http://share.domain2.com

You definitely don't need a second worker.

 Why do you need a second VirtualHost, even?
 
 Apache has to answer for that request (http://share.domain2.com)
 and pass it to tomcat

Sure, but you don't care what the target of the request is: everything
goes to the same backend, right?

 When i type http://share.domain2.com i arrive at 1 of our
 websites but not the tomcat content. When i type 
 http://share.domain2.com/share i get a 404 error. Do i need to 
 define another worker to accomplish this or should the defined 
 worker work for any domain given there is a virtualhost
 defined?
 
 Workers don't care about VirtualHosts: the client's request
 headers will be sent to Tomcat and another round of virtual host
 resolution will occur over there. Having separate workers does
 not help anything.
 
 I'm not sure why you are getting 404s: any idea if it's a
 response coming from httpd or Tomcat?
 
 No error logs in apache or tomcat which is weird?

Well, httpd should have something in its access log. Does Tomcat have
anything in its access log? If not, then httpd is returning the 404
and you don't have your mod_jk configuration correct. Can you post
more of your httpd.conf? Where do you have JkWorkersFile configured?

 If you browse to http://share.domain2.com/ are you properly
 redirected (as I would expect given the above configuration) to
 http://share.domain2.com/share ?
 
 It doesn't appear so as a apache site answers the request.

Apache httpd should be answering the request and responding with a
redirect. Does the redirect happen (check your URL bar, or use a
protocol sniffer like HttpFox, etc. through your web browser).

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJRXe37AAoJEBzwKT+lPKRYGfIP/iHb43djVfRdbAXDJSdbw598
L7DAZJrPkP6ttM0LLMjH9Iej7s1VMnY/3hVg5Yj/s1yh6kBi/vGt/BQubd5OcpxG
ah7XBGEy+fcV2pYvY6aE4cNj7zVUaabCUuR+dzdCeBB3b36PafPLnDyUxfBNzrK8
n3HqzfG4LrBiufmTZjTeIolD6V13ktt6aX7NJIC7exreATPQQPAJ4ztvdxbC1eRP
jrgEcG4Wh4gWsvW6jSiiRTeVLOg2DrWKTQ76/BD0DBxIYXPHMMR8JjTxMKEBAv5X
Om4LjWrbXPRpCBG1IsdPJaK8Xx+gWycvvzT5RGuFYwRsyeQe6LFhdip0k+T9TGvL
VxFE/N/aywY8r1a+Eg86SjRJnVPkVCrkyR33VtiXa76FMILq90BMqHHpK+i9aAx+
3pplfQYfmCGlGoJYg1Sjap8oPknz2Duundjj2+EAe1oE3ELL53XSbcRJYMgk6Ywq
phXYjIkLlKkl1h1uqDABxpirTBe2DEUS9FgPl8Mp7J3ASrKdDuIlxgmd9TDBqq7W
qMOUYseqHcbUIy+3NwE+8vF2u91/LJUMqHA/8P2iuvnJJyXVyptwKaas8G7Vbl50
vcCVJTeGJgn4h98Wqjm9CFW7dYKIwhJOhkyvzTUfSXWC3t3wukvA+/5k1Jx9oBPD
HOSzSP1UI9ugHxdeRUbN
=+DPt
-END PGP SIGNATURE-

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



Re: Serve same content to multiple URL's

2013-04-04 Thread Chris Arnold
 I didn't think I needed a second worker but because the working
 config only worked for http://share.domain1.com and nothing else, I
 wanted to verify it should work or I needed another worker and you
 verified I do not need another worker and in fact, the existing
 config for http://share.domain1.com should work for
 http://share.domain2.com

You definitely don't need a second worker.

Great! I know i am going in the right direction

 Why do you need a second VirtualHost, even?
 
 Apache has to answer for that request (http://share.domain2.com)
 and pass it to tomcat

Sure, but you don't care what the target of the request is: everything
goes to the same backend, right?

Correct. Goes to the same backend/content (static)

 I'm not sure why you are getting 404s: any idea if it's a
 response coming from httpd or Tomcat?
 
 No error logs in apache or tomcat which is weird?

Well, httpd should have something in its access log. Does Tomcat have
anything in its access log? If not, then httpd is returning the 404
and you don't have your mod_jk configuration correct. Can you post
more of your httpd.conf? Where do you have JkWorkersFile configured?

httpd.conf:
# mod_jk
Include /opt/alfresco/tomcat/conf/jk.conf

jk.conf:
IfModule mod_jk.c

JkWorkersFile /opt/alfresco/tomcat/workers.properties
JkLogFile /var/log/alfresco/mod_jk.log
JkShmFile /var/log/alfresco/shm

# Log level to be used by mod_jk
JkLogLevel error

 If you browse to http://share.domain2.com/ are you properly
 redirected (as I would expect given the above configuration) to
 http://share.domain2.com/share ?
 

Apache httpd should be answering the request and responding with a
redirect. Does the redirect happen (check your URL bar, or use a
protocol sniffer like HttpFox, etc. through your web browser).

It does not redirect. Browser stays at http://share.domain2.com
Will try to get some logs and post here

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



Re: Serve same content to multiple URL's

2013-04-04 Thread Chris Arnold
 I didn't think I needed a second worker but because the working
 config only worked for http://share.domain1.com and nothing else, I
 wanted to verify it should work or I needed another worker and you
 verified I do not need another worker and in fact, the existing
 config for http://share.domain1.com should work for
 http://share.domain2.com

You definitely don't need a second worker.

Great! I know i am going in the right direction

 Why do you need a second VirtualHost, even?
 
 Apache has to answer for that request (http://share.domain2.com)
 and pass it to tomcat

Sure, but you don't care what the target of the request is: everything
goes to the same backend, right?

Correct. Goes to the same backend/content (static)

 I'm not sure why you are getting 404s: any idea if it's a
 response coming from httpd or Tomcat?
 
 No error logs in apache or tomcat which is weird?

Well, httpd should have something in its access log. Does Tomcat have
anything in its access log? If not, then httpd is returning the 404
and you don't have your mod_jk configuration correct. Can you post
more of your httpd.conf? Where do you have JkWorkersFile configured?

httpd.conf:
# mod_jk
Include /opt/alfresco/tomcat/conf/jk.conf

jk.conf:
IfModule mod_jk.c

JkWorkersFile /opt/alfresco/tomcat/workers.properties
JkLogFile /var/log/alfresco/mod_jk.log
JkShmFile /var/log/alfresco/shm

# Log level to be used by mod_jk
JkLogLevel error

 If you browse to http://share.domain2.com/ are you properly
 redirected (as I would expect given the above configuration) to
 http://share.domain2.com/share ?
 

Apache httpd should be answering the request and responding with a
redirect. Does the redirect happen (check your URL bar, or use a
protocol sniffer like HttpFox, etc. through your web browser).

It does not redirect. Browser stays at http://share.domain2.com
Will try to get some logs and post here
OK, found where apache is logging this traffic to: a clients blog site. So now, 
when going to http://share.domain2.com, you get 1 of our clients blog sites? 
Definitely not redirecting. 

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