1

I am having a Spring MVC app which uses Spring Security for login. I am using Apache Webserver as Proxy and Tomcat. Below is my /etc/apache2/sites-enabled/example.com.conf file:

ServerAdmin admin@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public_html

ProxyPreserveHost On
ProxyRequests off

ProxyPass /myapp/j_spring_security_check http://localhost:8080/myapp/j_spring_security_check
ProxyPassReverse /myapp/j_spring_security_check http://localhost:8080/myapp/j_spring_security_check
ProxyPass /myapp http://localhost:8080/myapp
ProxyPassReverse /myapp http://localhost:8080/myapp

This works fine and I am able to log into my site. However, I have to use http://example.com/myapp instead of http://example.com. If I use later, it shows me:

Index of /

[ICO]   Name    Last modified   Size    Description
[IMG]   favicon.ico 2015-02-23 14:15    7.6K     

If I modify the example.com.conf file as suggested by other sites/posts, I get nothing and http://example.com takes me to http://example.com/myapp:

ProxyPass /j_spring_security_check http://localhost:8080/j_spring_security_check
ProxyPassReverse /j_spring_security_check http://localhost:8080/j_spring_security_check
ProxyPass / http://localhost:8080/myapp
ProxyPassReverse / http://localhost:8080/myapp

Can some one please help? Thanks.

Edit:

Below is my ROOT.xml in "~/apache-tomcat-7.0.52/conf/Catalina/localhost" folder which I created as per How to set the context path of a web application in Tomcat 7.0.

<Context
    docBase="/home/anuj/webapps/prod-prop-3" 
    path=""
    reloadable="true"
/>

But when I tried this, http://example.com took me to http://example.com/login and gave error:

The requested URL /login was not found on this server.

What is the issue here, can someone help please?

Community
  • 1
  • 1
AAgg
  • 494
  • 1
  • 3
  • 19

1 Answers1

0

Modify the httpd.conf with following proxy settings:

ProxyPass /j_spring_security_check http://localhost:8080/j_spring_security_check ProxyPassReverse /j_spring_security_check http://localhost:8080/j_spring_security_check ProxyPass /myapp http://localhost:8080/

ProxyPassReverse /myapp http://localhost:8080/

anil
  • 961
  • 1
  • 11
  • 23
  • It doesn't work. If I try http://example.com, I get the Index listing. If I try http://example.com/myapp, it displays nothing. – AAgg Feb 23 '15 at 13:41