SEARCH BY

All

  • All
  • Java8
  • Spring

Mapping domain with tomcat java application

Post a Comment

What is domain?

Domain is address to the application hosted in a webserver(like tomcat). for more details on domain visit www.godaddy.com

Change DNS settings of your domain to connect with your host system

Contact your hosting server admin to setup your server ip address with domain by chanding name servers in domain service provider.

Make port 80 to the public access

Contact your system admin ( who provided server instance to you) for example ctrls.in is Cloude service provider, so here you can contact ctrls.in support team for making 80 as public accessible

Changing tomcat port number to 80

After making 80 port as public visible we need to change tomcat port number to 80 by following the bello changes in server.xml file of tomat which is available in conf folder

    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
    -->
    <Connector port="80" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"  useIPVHosts="true" />

In the above code, in line 8 change port number to 80 in your server.xml file, here i have done

Adding host in server.xml file

Let us consider your domain is www.mysite.com, and your application is deployed in tomcat with the name as mycollege in webapps folder of tomcat.

<Host name="www.mysite.com" appBase="C:/apache-tomcat-9.0.37/webapps/mycollege" unpackWARs="true" autoDeploy="true">
<Alias>mysite.com</Alias>
<Context path="" docBase="C:/apache-tomcat-9.0.37/webapps/mycollege" debug="0" privileged="true" />
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" 
prefix="localhost_access_log." suffix=".txt" 
pattern="%h %l %u %t &quot;%r&quot; %s %b" resolveHosts="false" />
</Host>

Add the above code before closing Engine tag in server.xml file

In the above code try to replace www.mysite.com with your domain name and appBase path with your application location in webapps folder of tomcat

Then finally restart your tomcat and access website with www.mysite.com/mycollege url in a browser

jaya
I love software designing, coding, writing and teaching...

Share this article

Related Posts

Post a Comment

Place your code in <em> </em> tags to send in comments | Do not add hyper links in commnet

Close

Subscribe our newsletter for the latest articles directly into your email inbox