pedja
pedja

Reputation: 3413

Setup subdomain in tomcat7

I have both apache2 and tomcat7 installed on my server
apache runs on port 80 and tomcat on port 8080

My domain pedjaapps.net points to my server ip and that works fine(apache handles it as it should)

Now i want my subdomain api.pedjapps.net on port '8080' to point to subfolder api on tomcat server

i tried editing server.xml and adding something like this:

<Host appbase="webapps/api" autodeploy="true" name="api.pedjaapps.net" unpackwars="true" xmlnamespaceaware="false" xmlvalidation="false">
    <Context docbase="/var/lib/tomcat7/webapps/api" path="" reloadable="true"></Context>
</Host>

but it still opens default tomcat page

api.pedjaapps.net also points to my servers ip in dns, if that is relavent

Upvotes: 3

Views: 3942

Answers (1)

Khary Mendez
Khary Mendez

Reputation: 1858

If you don't need the default tomcat page, remove (or rename) webapps/ROOT then change the name of webapps/api to ROOT. This will make your api web application the default tomcat application. This is a quick (and dirty) solution if it meets your needs.

If this is not sufficient, you can set up virtual hosts in either apache or tomcat. If done in tomcat, you will need to have each virtual host point to a separate webapps area. See this for setup: http://tomcat.apache.org/tomcat-7.0-doc/virtual-hosting-howto.html

Upvotes: 2

Related Questions