How To Map A Domain To Tomcat’s Web Application

When you deployed your application in Tomcat server you can view your app by the link like: http://localhost:port/appName. You can mapping a domain to Tomcat’s web application to access your application according by your domain (ex: http://yourdomain.com) after you reference the domain to your ip server.
To do this you flow theses steps:
Step 1: Open file server.xml in folder C:/Tomcat7.2/conf.
Setp 2: Change port of http tomcat to 80. This look like:

<Connector port="80" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

Step 3: Add new virtual host entry just before last closing Engine tag

<Host name="yourdomain.com" 
		  appBase="C:/Tomcat7.2/webapps/yourapp"
		  unpackWARs="true" 
		  autoDeploy="true" 
		  xmlValidation="false" 
		  xmlNamespaceAware="false">
	   
		   <Alias>doithoaitructuyen.msb.com.vn</Alias>

		   <Context path="" docBase="C:/Tomcat7.2/webapps/yourapp" 
			   debug="0" reloadable="false"/>
		   <Context path="/yourapp" docBase="C:/Tomcat7.2/webapps/yourapp" 
			  debug="0" reloadable="false"/>
	 </Host>

Step 3: Save file and restart apache tomcat.

Happy coding!

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s