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.
Your port numbers should be fine: Tomcat is listening on
8080
and Apache httpd is listening on80
. If you wanthttp://www.myapp.com/
to go to your webapp, then you'll have to adjust yourProxyPass
configuration:That configuration is not valid, since
ProxyPassReverse
requires two arguments. I think you want something like this:If you do the above, then everything will be proxied-over to Tomcat. (At this stage its worth asking yourself why you are bothering with Apache httpd at all, since everything is being proxied). You'll also want to set
proxyPort
to 80 in your<Connector>
inserver.xml
.If you want
/index.html
to work, and not show you the Tomcat "success" page that comes with it, then you need to re-name your webapp fromMyAppPath
toROOT
(case matters: it must be upper-case). Just re-name your webapp's directory toROOT
or your WAR file toROOT.war
and you should be good to go.If you just want to use port 80 and don't need Apache httpd for anything else, then simply change Tomcat's
server.xml
so that your<Connector>
for port 8080 is instead using port 80, and remove Apache httpd from the mix altogether.