简体   繁体   中英

Same Host/server name for different virtual host

I have deployed 3 applications in 3 Tomcat Instances

http://host:8080/app0
http://host:8081/app1
http://host:8082/app2

and I have the workers.properties as

worker.list= worker1,worker2,worker3

# Set properties for worker 'example' (ajp13)

worker.worker1.host=host
worker.worker1.port=8009
worker.worker1.type=ajp13

# Set properties for worker 'example' (ajp13)

worker.worker2.host=host
worker.worker2.port=8019
worker.worker2.type=ajp13

# Set properties for worker 'example' (ajp13)

worker.worker3.host=host
worker.worker3.port=8029
worker.worker3.type=ajp13

How my httpd.conf should look like? All the virtual host can have the same server name as like below

# app0 instance virtual host
<VirtualHost *:80>
ServerName host
DocumentRoot TOMCAT_HOME"\Tomcat Instance 1\webapps"
ErrorLog logs/app0.log
JkMount /app0 worker1
</VirtualHost>

# app1 instance virtual host
<VirtualHost *:80>
ServerName host
DocumentRoot TOMCAT_HOME"\Tomcat Instance 2\webapps"
ErrorLog logs/app1.log
JkMount /app1 worker2
</VirtualHost>

# app2 instance virtual host
<VirtualHost *:80>
ServerName host
DocumentRoot TOMCAT_HOME"\Tomcat Instance 2\webapps"
ErrorLog logs/app2.log
JkMount /app2 worker3 
</VirtualHost>

can any one help me? If I use mod proxy I am getting 502 Proxy error intermittently so thought of doing with mod jk.

I am not sure about Tomcat part of it but here's what I would do

Forget about different ports (you could if you want to but it's not necessary if all you want to do is set up virtual hosts)

To access

http://host/app0
http://host/app1
http://host/app2

Modify httpd.conf as

<VirtualHost *>
  ServerName host
  DocumentRoot TOMCAT_HOME"\Tomcat Instance 2\webapps"
  Alias /app0 APP0_ROOT_HERE
  Alias /app1 APP1_ROOT_HERE
  Alias /app2 APP2_ROOT_HERE
</VirtualHost>

This configuration will handle all requests that have server name "host" and if it matches any of the aliases, will use the indicated document root. If not alias is matched, it will use the default document root. Not sure about separate logging but it should be possible, check out http://httpd.apache.org/docs/2.2/vhosts/name-based.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM