简体   繁体   中英

How to map an app from Tomcat8 to Apache in JBoss Web Server?

I install JBoss 3.0.1 and it functions well both Apache on port 80 & Tomcat8 on port 8080. I deploy a sample war file from Tomcat and can view it at http://localhost:8080/sample/ .

So is it possible to map it on Apache, then we can access it at http://localhost/sample/ ? If yes, can you please help me how to do that? Any suggestion would be appreciated.

Update: For POC purpose, the OS is Windows 7

You can do it by means of AJP. You don't specify what OS are you using, but I will assume it is GNU/Linux, although instructions for MS Windows will be similar.

The procedure is the following:

  • Install Apache module for AJP, usually it is called something like libapache2-mod-jk . ( In debian/ubuntu you can run sudo apt-get install libapache2-mod-jk ).
  • Then you will have a new module called jk or similar. You have to enable it ( In debian/ubuntu you can run sudo a2enmod jk ).
  • Default configuration will serve mostly, open it a see where does JkWorkersFile point. This file is needed to configure the workers that manage communication with tomcat apps.
  • Create workers file ( if it does not exists ). A workers file is more or less as following.

Sample workers file:

ps=/
worker.list=worker1,worker2,...

# worker1 definition
worker.worker1.port=8009
worker.worker1.host=192.168.1.23
worker.worker1.type=ajp13

# worker2 definition
....

Every worker can point to different tomcat server. Port must be the same that configured into $CATALINA_HOME/conf/server.xml . In this file there is a connector for AJP protocol:

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

Every worker has to point to this port.

Finally, you can configure virtual host, locations, etc. into Apache with JkMount workerName to indicate Apache that this url has to be forwarded to the proper worker.

There are plenty of samples an documentation. Here you are with Tomcat official docs: https://tomcat.apache.org/connectors-doc/webserver_howto/apache.html

Hope it helps!

Edit

If you are using MS Windows, you can download mod_jk from this url https://tomcat.apache.org/download-connectors.cgi

Install it and configure as suggested. Due to you want to map this url http://localhost/sample to tomcat app in http://localhost:8080/sample Your configuration must be the following:

workers file ( Review port with server.xml tomcat conf file ):

worker.list=worker1

# worker1 definition
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13

Apache Location directive ( Review order, deny and allow to suit your needs ):

<Location /sample/>
    JkMount worker1
    Order deny,allow
    Deny from all
    Allow from localhost
</Location>

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