[Apache/Tomcat] Virtual Host configuratie

Pagina: 1
Acties:
  • 352 views sinds 30-01-2008
  • Reageer

  • turkosh
  • Registratie: December 2003
  • Laatst online: 26-04-2025
Ik heb menig topic over dit onderwerp uitgezocht en door gespit maar heb nog geen oplossing kunnen vinden.

Ik draai apache 2 en tomcat 6.0.14 die via mod_jk aan elkaar worden gelinkt.
Hier is mijn standaard cofiguratie (apache laat ik buiten beschouwing want die werkt):
XML:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
...
<Connector port="8309"
               enableLookups="false" redirectPort="8743" protocol="AJP/1.3" />

<Engine name="Catalina" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>

      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

      <Host name="localhost.myapp.com" appBase="webapps/myapp" 
            unpackWARs="true" autoDeploy="true">
        <Context path="" docBase="" reloadable="true"/>         
      </Host>
</Engine>


Dit is bereilbaar via myapp.com (apache). Enige probleem is dubbele init van de applicatie.

Ik heb onder de <tomcat> dir een nieuwe folder gemaakt met de naam hosts4apps (dus pad is <tomcat>/host4apps).

Ik pas de httpd.conf in apache aan met de volgende DocumentRoot voor de VH:
DocumentRoot "c:/Tomcat-6.0/hosts4apps/myapp"

en in server.xml wijzig ik de tweede host als volgt:
XML:
1
2
3
4
<Host name="localhost.myapp.com" appBase="host4apps" 
      unpackWARs="true" autoDeploy="true">
    <Context path="" docBase="" reloadable="true"/>         
</Host>


Als ik mijn war file in de host4apps folder zet wordt die netjes door tomcat uitgepakt. Maar ik krijg een 404 terug als ik localhost.myapp.com intoets in mijn browser.

  • SPee
  • Registratie: Oktober 2001
  • Laatst online: 12:28
En wat gebeurd er als je het direct op de tomcat poort opvraagt :?
Kan Apache de request netjes doorsturen naar Tomcat, of geeft apache die 404 :?

let the past be the past.


  • NMe
  • Registratie: Februari 2004
  • Laatst online: 22-01 23:51

NMe

Quia Ego Sic Dico.

'E's fighting in there!' he stuttered, grabbing the captain's arm.
'All by himself?' said the captain.
'No, with everyone!' shouted Nobby, hopping from one foot to the other.


  • turkosh
  • Registratie: December 2003
  • Laatst online: 26-04-2025
Sorry voor de topic messup ;-)

Ik heb een fix gevonden voor het probleem. Kennelijk moet de docBase wijzen naar de applicatienaam (in dit geval dus dosBase="myapp").
Dan blijkt het te werken. Kan vanuit apache netjes de applicatie aanroepen. Het probleem hierbij is weer dat mijn applicatie 2 keer wordt geinit. Daarnaast wordt de applicatie uitgepakt in de ROOT folder onder host (wat niet echt netjes vind, heb liever myapp als folder).
Door toevoeing van deployOnStartup="false" in <host> tag kon ik de applicatie 1 keer laten initialiseren. Heb geen fix voor ROOT folder gevonden, maar misschien moet ik blij zijn dat het nu werkend is.