Reputation: 639
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.
Upvotes: 4
Views: 23027
Reputation: 54
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!
Upvotes: 3
Reputation: 20882
Your port numbers should be fine: Tomcat is listening on 8080
and Apache httpd is listening on 80
. If you want http://www.myapp.com/
to go to your webapp, then you'll have to adjust your ProxyPass
configuration:
ProxyPass /MyAppPath http://localhost:8080
ProxyPassReverse http://localhost:8080
That configuration is not valid, since ProxyPassReverse
requires two arguments. I think you want something like this:
ProxyPass / http://localhost:8080
ProxyPassReverse / http://localhost:8080
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>
in server.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 from MyAppPath
to ROOT
(case matters: it must be upper-case). Just re-name your webapp's directory to ROOT
or your WAR file to ROOT.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.
Upvotes: 1