Apache+mod_jk+tomcat配置虚拟主机不同域名跳转

时间:2022-12-07 16:53:16
Apache+mod_jk+tomcat配置虚拟主机不同域名跳转

以下配置实现了,用apache虚拟主机配置不同的域名,通过mod_jk,跳转到tomcat的相同uri地址,却不相同的tomcat目录。呵呵,说着有点绕嘴!反正就是这么用的~~~当有这样的需求的时候就会明白是怎么回事了!我这也是有次帮朋友忙时,按照他的需求帮他配置的~~~在这奉献给有需要的朋友们!

Apachehttpd.conf文件配置:

NameVirtualHost *:80

<VirtualHost *:80>

#<VirtualHost 10.10.10.10:80>

    DocumentRoot/usr/local/apache2/htdocs/a/

    ServerName a-test.com

    ServerAlias a-test.com

    <Location"/path/*">

        JkUriSetworker ajp13:localhost:8009

   </Location>

</VirtualHost>

<VirtualHost *:80>

#<VirtualHost 10.10.10.10:80>

    DocumentRoot/usr/local/apache2/htdocs/b/

    ServerName b-test.com

    ServerAlias b-test.com

    <Location"/path/*">

        JkUriSetworker ajp13:localhost:8109

   </Location>

</VirtualHost>

配置workers2.properties文件: 下面的三组配置由上到下是相联系的!仔细看一下就会明白的!呵呵~~~

[channel.socket:localhost:8009]

port=8009

host=127.0.0.1

[channel.socket:localhost:8109]

port=8109

host=127.0.0.1

 

# define the worker

[ajp13:localhost:8009]

channel=channel.socket:localhost:8009

# define the worker

[ajp13:localhost:8109]

channel=channel.socket:localhost:8109

 

# Uri mapping

[uri:a-test.com/path/*]

worker=ajp13:localhost:8009

# Uri mapping

[uri:b-test.com/path/*]

worker=ajp13:localhost:8109

本文出自 “高兴F” 博客,请务必保留此出处http://gaoxingf.blog.51cto.com/612518/193209