Apache forwarding to tomcat shows a blank page
Matching trailing slashes are important in mod_proxy.
ProxyPass / http://www.example.com:9090/mycontext
This will take a request to http://www.abc.com/something
and proxy it to http://www.example.com:9090/mycontextsomething
- not terribly helpful!
Try this configuration, instead:
ProxyPass / http://www.example.com:9090/mycontext/
ProxyPassReverse / http://www.example.com:9090/mycontext/
Also - if Tomcat's expecting www.example.com
as a host header, then you probably do not want that ProxyPreserveHost On
directive.
Related videos on Youtube
user10211
Updated on September 18, 2022Comments
-
user10211 over 1 year
I have an application running on tomcat at
http://www.example.com:9090/mycontext
. The host name inserver.xml
points towww.example.com
. I do not havelocalhost
anymore. I am using apache to forward requests to tomcat usingmod_proxy
. Things work fine as long as theProxyPath
is/mycontext
. The server name setup in virtual host iswww.abc.com
andhttp://www.abc.com/mycontext
works fine. However I would like to ignore the context path and simply usehttp://www.abc.com/
to forward requests tohttp://www.example.com:9090/mycontext
. When I do this, apache shows me a blank page. What am I missing here? I have not changed anything inserver.xml
except the default host towww.example.com
.<VirtualHost *:80> ServerName www.abc.com ProxyRequests Off ProxyPreserveHost On <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass / http://www.example.com:9090/mycontext ProxyPassReverse / http://www.example.com:9090/mycontext </VirtualHost>
Thanks
-
meulop about 12 yearsCan you add the relevant bits of your httpd.conf file to the question?
-
user10211 about 12 yearsI have added the virtual host settings. Is there anything else I should add?
-
-
ravi yarlagadda about 12 yearsIs it Apache's "It works" page, or Tomcat's?
-
user10211 about 12 yearsIt is Apache's "It works page."
-
ravi yarlagadda about 12 yearsInteresting... are you sure the request to
/
has the correct host header to get mapped to this virtual host? -
user10211 about 12 yearsI checked the apache access log. It shows that a request made to / gets directed to /mycontext/. Should it explicitly show example.com:9090/mycontext
-
ravi yarlagadda about 12 yearsAhh, I see. Do you need for it to make that request without the trailing slash? That'll be more complicated to add to the config.
-
user10211 about 12 yearsEssentially my tomcat setup is serving a JSP page at :9090/mycontext/ and I would like http: //www.abc.com/ to get redirected to this page. Does it involve rewrite rules setting up for just this redirection ?
-
ravi yarlagadda about 12 yearsNo, that should be working just fine. Can you clarify what you meant by "It shows that a request made to / gets directed to /mycontext/" - is that not what you're looking to achieve?