You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Darren Kukulka <Da...@connaught.plc.uk> on 2007/03/06 11:17:39 UTC

Named based virtual host redirection

Hi there

 

I'm doing some testing of redirection with a separate Apache web farm
serving front end redirection of specific tags to Tomcat server via an
ajp13 worker.

 

The problem I'm coming across is redirecting a DNS alias to a specific
tag on the same web server.  I've been trying virtual host directives,
to no avail (the ajp13 redirection works for normal tags). The
configuration is as follows;

 

httpd.conf

 

LoadModule jk_module modules/mod_jk.so

JkWorkersFile conf/workers.properties

JkShmFile     logs/mod_jk.shm

JkLogFile     logs/mod_jk.log

JkLogLevel    info

JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

JkMount  /app1/* worker1

ServerName  fred.abc.co.uk

DocumentRoot "D:/Apache2/htdocs"

Include conf/extra/httpd-vhosts.conf

 

httpd-vhosts.conf

 

NameVirtualHost 1.2.3.4:80

 

<VirtualHost 1.2.3.4:80>

    DocumentRoot d:/apache2/htdocs

    ServerName test.abc.co.uk

    Redirect / http://fred.abc.co.uk/app1/

</VirtualHost>

 

workers.properties

 

worker.list=worker1

worker.worker1.type=ajp13

worker.worker1.host=1.2.3.5

worker.worker1.port=8009

 

Now if I hit the http://fred.abc.co.uk/app1/ without the vhosts include,
the site comes up...great!   If I include the vhosts, and try to hit
http://test.abc.co.uk <http://test.abc.co.uk/>  without an appended
/app1/ tag (this is what I'm trying to achieve) to get the same site, I
get nothing at all....in fact, it times out.  In the Apache web server
logs all I see is a recursive get on /app1/.  Also, the original URL
does not work any more.

 

This seems to be a simple requirement but it is not proving to be
straightforward.

 

Can anybody help, or point me in the right direction?

 

Darren Kukulka

IT Infrastructure Consultant

Conntrol

Connaught PLC

 




Connaught honoured AIM 'Decade of Excellence' Award 

Connaught awarded Partnering Contractor of the Year 2005 

Connaught wins AIM 'Company of the Year' award 2004 

West of England Business of the Year Award Winner 2003 

Why not visit our website http://www.connaught.plc.uk 
Disclaimer: 

The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete this message. 



Connaught plc, Head Office 01392 444546 

Re: Named based virtual host redirection

Posted by Pid <p...@pidster.com>.
Darren Kukulka wrote:
> Hassan,
> 
> All the static content is served by Tomcat anyway...i.e - there is no
> content on the Apache web server.
> 
> How is the mod_proxy_ajp used?  The doco on Apache org refers to it in a
> developer sense, rather than as a web server directive.

the pertinent info is actually on the mod_proxy page - it's largely 
config free if you're using it with the Tomcat AJP connector.

  ProxyPass /app ajp://hostname:ajpport/app

You can also use the [p] Proxy directive for mod_rewrite

  RewriteRule  ^/(.+)\.jsp(x?)(.+)*  ajp://hostname:ajpport/$1.jsp$2$3

(...or something, the regex *probably* works)



> -----Original Message-----
> From: Hassan Schroeder [mailto:hassan.schroeder@gmail.com] 
> Sent: 06 March 2007 15:27
> To: Tomcat Users List
> Subject: Re: Named based virtual host redirection
> 
> On 3/6/07, Darren Kukulka <Da...@connaught.plc.uk> wrote:
> 
>> This worked but I want to hide the redirect URL,
> 
> and eliminate the doubled network traffic, I hope? :-)
> 
> Anyway,
> 
>> <VirtualHost *:80>
>>     DocumentRoot d:/apache2/htdocs
>>     ServerName test.abc.co.uk
>>     ProxyPass / http://fred.abc.co.uk/app1/
>>     ProxyPassReverse / http://fred.abc.co.uk/app1/
>> </VirtualHost>
>>
>> This almost works, but it only appears to show the html content, not
> the
>> JSP.  Does anybody have any suggestions how to make this work?
> 
> 1. move your static content to Tomcat,
> 2. use mod_proxy_ajp instead of mod_jk
> 
> FWIW!


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


RE: Named based virtual host redirection

Posted by Darren Kukulka <Da...@connaught.plc.uk>.
Hassan,

All the static content is served by Tomcat anyway...i.e - there is no
content on the Apache web server.

How is the mod_proxy_ajp used?  The doco on Apache org refers to it in a
developer sense, rather than as a web server directive.

-----Original Message-----
From: Hassan Schroeder [mailto:hassan.schroeder@gmail.com] 
Sent: 06 March 2007 15:27
To: Tomcat Users List
Subject: Re: Named based virtual host redirection

On 3/6/07, Darren Kukulka <Da...@connaught.plc.uk> wrote:

> This worked but I want to hide the redirect URL,

and eliminate the doubled network traffic, I hope? :-)

Anyway,

> <VirtualHost *:80>
>     DocumentRoot d:/apache2/htdocs
>     ServerName test.abc.co.uk
>     ProxyPass / http://fred.abc.co.uk/app1/
>     ProxyPassReverse / http://fred.abc.co.uk/app1/
> </VirtualHost>
>
> This almost works, but it only appears to show the html content, not
the
> JSP.  Does anybody have any suggestions how to make this work?

1. move your static content to Tomcat,
2. use mod_proxy_ajp instead of mod_jk

FWIW!
-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

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




Connaught honoured AIM 'Decade of Excellence' Award 

Connaught awarded Partnering Contractor of the Year 2005 

Connaught wins AIM 'Company of the Year' award 2004 

West of England Business of the Year Award Winner 2003 

Why not visit our website http://www.connaught.plc.uk 
Disclaimer: 

The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete this message. 



Connaught plc, Head Office 01392 444546 

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


Re: Named based virtual host redirection

Posted by Hassan Schroeder <ha...@gmail.com>.
On 3/6/07, Darren Kukulka <Da...@connaught.plc.uk> wrote:

> This worked but I want to hide the redirect URL,

and eliminate the doubled network traffic, I hope? :-)

Anyway,

> <VirtualHost *:80>
>     DocumentRoot d:/apache2/htdocs
>     ServerName test.abc.co.uk
>     ProxyPass / http://fred.abc.co.uk/app1/
>     ProxyPassReverse / http://fred.abc.co.uk/app1/
> </VirtualHost>
>
> This almost works, but it only appears to show the html content, not the
> JSP.  Does anybody have any suggestions how to make this work?

1. move your static content to Tomcat,
2. use mod_proxy_ajp instead of mod_jk

FWIW!
-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

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


RE: Named based virtual host redirection

Posted by Darren Kukulka <Da...@connaught.plc.uk>.
Further to this I modified the httpd-vhosts.conf file, after discovering
that the main server will not serve the jkmount directives if virtual
hosts are active...hence the looping and no response...

NameVirtualHost 1.2.3.4:80
<VirtualHost *:80>
    DocumentRoot d:/apache2/htdocs
    ServerName fred.abc.co.uk
    JkMount  /app1/* worker1
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot d:/apache2/htdocs
    ServerName test.abc.co.uk
    Redirect / http://fred.abc.co.uk/app1/
</VirtualHost>

This worked but I want to hide the redirect URL, so I tried using
proxypass as follows for the second virtual host...

<VirtualHost *:80>
    DocumentRoot d:/apache2/htdocs
    ServerName test.abc.co.uk
    ProxyPass / http://fred.abc.co.uk/app1/
    ProxyPassReverse / http://fred.abc.co.uk/app1/
</VirtualHost>

This almost works, but it only appears to show the html content, not the
JSP.  Does anybody have any suggestions how to make this work?

-----Original Message-----
From: Darren Kukulka [mailto:Darren.Kukulka@connaught.plc.uk] 
Sent: 06 March 2007 10:18
To: Tomcat Users List
Subject: Named based virtual host redirection

Hi there

 

I'm doing some testing of redirection with a separate Apache web farm
serving front end redirection of specific tags to Tomcat server via an
ajp13 worker.

 

The problem I'm coming across is redirecting a DNS alias to a specific
tag on the same web server.  I've been trying virtual host directives,
to no avail (the ajp13 redirection works for normal tags). The
configuration is as follows;

 

httpd.conf

 

LoadModule jk_module modules/mod_jk.so

JkWorkersFile conf/workers.properties

JkShmFile     logs/mod_jk.shm

JkLogFile     logs/mod_jk.log

JkLogLevel    info

JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

JkMount  /app1/* worker1

ServerName  fred.abc.co.uk

DocumentRoot "D:/Apache2/htdocs"

Include conf/extra/httpd-vhosts.conf

 

httpd-vhosts.conf

 

NameVirtualHost 1.2.3.4:80

 

<VirtualHost 1.2.3.4:80>

    DocumentRoot d:/apache2/htdocs

    ServerName test.abc.co.uk

    Redirect / http://fred.abc.co.uk/app1/

</VirtualHost>

 

workers.properties

 

worker.list=worker1

worker.worker1.type=ajp13

worker.worker1.host=1.2.3.5

worker.worker1.port=8009

 

Now if I hit the http://fred.abc.co.uk/app1/ without the vhosts include,
the site comes up...great!   If I include the vhosts, and try to hit
http://test.abc.co.uk <http://test.abc.co.uk/>  without an appended
/app1/ tag (this is what I'm trying to achieve) to get the same site, I
get nothing at all....in fact, it times out.  In the Apache web server
logs all I see is a recursive get on /app1/.  Also, the original URL
does not work any more.

 

This seems to be a simple requirement but it is not proving to be
straightforward.

 

Can anybody help, or point me in the right direction?

 

Darren Kukulka

IT Infrastructure Consultant

Conntrol

Connaught PLC

 




Connaught honoured AIM 'Decade of Excellence' Award 

Connaught awarded Partnering Contractor of the Year 2005 

Connaught wins AIM 'Company of the Year' award 2004 

West of England Business of the Year Award Winner 2003 

Why not visit our website http://www.connaught.plc.uk 
Disclaimer: 

The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you
received this in error, please contact the sender and delete this
message. 



Connaught plc, Head Office 01392 444546 

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