Remove tomcat port number in the http URL

Satish Jonnala picture Satish Jonnala · Dec 10, 2013 · Viewed 19.6k times · Source

I have a webapplication hosted on tomcat. I'm trying to achieve a URL redirection of my webappname. So, I'm using the vhosts config in apache of my xampp installation.

My tools : Tomcat, XAMPP, APACHE

Changes I made :

In /System32/drivers/etc/hosts
127.0.0.1 www.myapp.com

Also, I requested for a domain name.

nslookup myapp.com
Server: xxx.xx.xxx.xxx
Address:    xxx.xx.xxx.xxx#53

myapp.com   canonical name = blah-blah-myapp.com.
Name:   myapp.com
Address: xxx.xx.xxx.xxx

In tomcat server.xml :

     <Connector className="org.apache.catalina.connector.http.HttpConnector"
            connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"
            proxyName="www.myapp.com"
            proxyPort="80"/>

In httpd.conf :

LoadModule proxy_module  modules/mod_proxy.so
#AddModule  mod_proxy.c  # Gave error when tried to follow the docs

ProxyPass         /MyAppPath  http://localhost:8080/MyAppPath
ProxyPassReverse  /MyAppPath  http://localhost:8080/MyAppPath

In http-vhosts.conf :

<VirtualHost *:80>
ServerName myapp.com
ServerAlias www.myapp.com
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
    Order deny,allow
    Allow from all
</Proxy>
ProxyPass /MyAppPath http://localhost:8080
ProxyPassReverse http://localhost:8080

By making these configurations, I achieved the functionality in my Macintosh machine. But, the problem is with windows server. I made the same changes in windows installation config files. It not skipping the PORT number. My app only works with the port number infront of the domain name. How can I make the http request on port 80 to redirect to tomcat port 8080

All I'm looking for is to implement something like www.myapp.com instead of localhost:8080/index.html. My app is running on port 8080. After the above config changes, i'm able to access the application with www.myapp.com:8080. I want to eliminate the 8080 from the url.

Answer

wai picture wai · Jan 31, 2018

Your problem

http://192.9.200.192:8080/myService/my/BaseService/base

OPEN

C:\Program Files\Apache Software Foundation\Tomcat 7.0\conf\sever.xml

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

EDIT

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

open Configure tomcat from start menu if the service stop condition restart it (stop -> start)

call URL like this

http://192.9.200.192/myService/my/BaseService/base

Problem solved!