0

I have a web application project with very large media files and I would like them seperate from the rest of the application but remain in the same path.

So for example,if I have a file in the apache document root:

/var/www/html/myapp1/media/bigFile.wmv 

but the rest of my app resides in the tomcat app directory:

/usr/share/tomcat/webapps/myapp1/

is there a way to see if Apache has the file and then if not look in Tomcat and then if nothing is found then give the 404?

I've tried doing this just now and got a tomcat 404. This is because my tomcat is running behind Apache and all requests are sent directly to tomcat.

Is there a way to see if Apache has the file, then if not found, look in Tomcat and then, if nothing is found again, then give the 404?

It would also be preferential is the opposite were true, if I could go from tomcat to apache to 404, I could just drop the entire application + media files in apache, then drop new versions of the app in tomcat. I wouldn't have to do a diff between the two directories.

Here is my current configuration file I use for tomcat:

<VirtualHost *:80>
   ServerName localhost
   ServerAlias website.com

   ProxyRequests Off
   ProxyPreserveHost On

   ErrorLog /var/log/httpd/tomcat.error.log
   CustomLog /var/log/httpd/tomcat.log combined

   <Proxy *>
           Order deny,allow
           Allow from all
   </Proxy>

   ProxyPass / http://localhost:8080/
   ProxyPassReverse / http://localhost:8080/
</VirtualHost>
0

You can try apache mod_jk. This enables you to run tomcat behind apache. You specifically need to use the option JkMount (in addition to other options) to redirect specific URLs to tomcat from apache.

A URL not directed to tomcat and not available in apache will cause 404 HTTP error.

To make things easier to you when implementing such setup, verify tomcat is working alone and apache is working alone. Then, try to connect them.

  • So I would have to redirect every link individually? – Native Jul 29 '15 at 14:58
  • 1
    @Native: You can wildcard redirect like /*.jsp. – Khaled Jul 29 '15 at 15:06
  • I've included my configuration file in my question, I currently use a proxy pass as I have many projects. If i wanted to single out my a specific project, should I make another configuration file specific to that project? How would I "target" that project? – Native Jul 29 '15 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.