Apache Vhost & JkAutoAlias - accès statique via workers ?
Bonjour,
Je reprends tout à zéro parce que je n'étais pas forcément très clair...
• Je dispose d’une application web JBoss (4.2) MyApp dont une des pages JSP permet d’afficher des images TIF avec le plugin Alternatiff (http://www.alternatiff.com) via l'URL des images.
• Mon environnement est constitué de deux machines Linux : machine1, machine2
o Sur machine1 :
- Serveur Apache + mod_jk utilisant une paire de « balanced workers » pour accéder à deux instances de MyApp
- JBoss contenant la première instance de MyApp (connecté à apache via workers)
o Sur machine2 :
- JBoss contenant la seconde instance de MyApp (connecté à apache via workers)
• Sur chaque machine, MyApp est installée dans « /work/MyApp ».
• Les fichiers de configuration Apache & workers :
MyApp.vhost:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| # vhost for MyApp
Listen MyApp-t.internal:80
# Include the workers.properties file
Include workers.properties.d/MyApp.workers.properties
<VirtualHost MyApp-t.internal:80>
ServerName MyApp
ServerAlias MyApp*
DocumentRoot /work/MyApp/htdoc
ErrorLog "|/usr/sbin/rotatelogs2 /log/MyApp/http/error_log_MyApp 86400"
CustomLog "|/usr/sbin/rotatelogs2 /log/MyApp/http/access_log_MyApp 86400" extended-combined
JkAutoAlias /work/MyApp
# URI's mapped to tomcat workers
JkMount / MyApp_loadbalancer
JkMount /* MyApp_loadbalancer
JkUnMount /*.TIF* MyApp_loadbalancer
</VirtualHost> |
MyApp.workers.properties:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| # Define the list of workers that will be used for mapping requests
JkWorkerProperty worker.list=MyApp_loadbalancer
# Define MyApp_0
# Modify the host per your host IP or DNS name.
JkWorkerProperty worker.MyApp_0.port=8009
JkWorkerProperty worker.MyApp_0.host=machine1
JkWorkerProperty worker.MyApp_0.type=ajp13
JkWorkerProperty worker.MyApp_0.lbfactor=1
JkWorkerProperty worker.MyApp_0.cachesize=10
JkWorkerProperty worker.MyApp_0.connect_timeout=2000
JkWorkerProperty worker.MyApp_0.prepost_timeout=2000
JkWorkerProperty worker.MyApp_0.reply_timeout=45000
JkWorkerProperty worker.MyApp_0.secret=aBcDeFgHe
# Define MyApp_1
# Modify the host per your host IP or DNS name.
JkWorkerProperty worker.MyApp_1.port=8009
JkWorkerProperty worker.MyApp_1.host=machine2
JkWorkerProperty worker.MyApp_1.type=ajp13
JkWorkerProperty worker.MyApp_1.lbfactor=1
JkWorkerProperty worker.MyApp_1.cachesize=10
JkWorkerProperty worker.MyApp_1.connect_timeout=2000
JkWorkerProperty worker.MyApp_1.prepost_timeout=2000
JkWorkerProperty worker.MyApp_1.reply_timeout=45000
JkWorkerProperty worker.MyApp_1.secret=aBcDeFgHe
# Define load balancing behaviour with the loadbalancer worker.
# It manages the workers that are mentioned in balance_workers directive
# Note that workers are mentioned in balanced_workers MUST NOT be mentioned in
# worker.list directive
JkWorkerProperty worker.MyApp_loadbalancer.type=lb
JkWorkerProperty worker.MyApp_loadbalancer.balanced_workers=MyApp_0,MyApp_1 |
• Les workers fonctionnent bien pour Tomcat/JBoss.
• Lorsqu’une session de MyApp tourne sur machine1 :
L’URL « MyApp-t.internal/data/image.TIF » correspondant à une image générée en session dans « /work/MyApp/data/image.TIF » est bien valide puisque le VHOST y est bien défini.
• Lorsqu’une session de MyApp tourne sur machine2 :
L’URL « MyApp-t.internal/data/image.TIF » théoriquement correspondant à une image générée en session dans « /work/MyApp/data/image.TIF » est invalide puisque le VHOST est uniquement défini sur machine1. => Soit il n’y a pas d’image sur machine1 et on a un beau message « not found », soit il y une image mais ce n’est pas celle qu’on attendait puisqu’on n’est pas sur la bonne machine…
Question : Comment servir ce contenu statique dans mes répertoires d’installation de MyApp sur machine1 ou sur machine2 de façon transparente pour que l’URL « MyApp-t.internal/data/image.TIF » pointe sur le répertoire « /work/MyApp/data/image.TIF » sur la machine d’où la session est en train de tourner ? Comment servir ce contenu via les workers ?
Merci d'avance pour tout coup de main! :aie:
David
PS. Je découvre +/- aussi