logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Third-party Modules View previous topic :: View next topic
Reply to topic   Topic: Serving static content with Apache web server and Tomcat
Author
Hunter



Joined: 27 Feb 2011
Posts: 1

PostPosted: Sun 27 Feb '11 3:32    Post subject: Serving static content with Apache web server and Tomcat Reply with quote

I've configured Apache web server and Tomcat like this:

I created a new file in apache2/sites-available, named it "myDomain" with this content:
Code:
<VirtualHost *:80>

ServerAdmin admin@myDomain.com
ServerName myDomain.com
ServerAlias www.myDomain.com

ProxyPass / ajp://localhost:8009

<Proxy *>
AllowOverride AuthConfig
Order allow,deny
Allow from all
Options -Indexes
</Proxy>

</VirtualHost>


Enabled mod_proxy and myDomain
Code:
a2enmod proxy_ajp
a2ensite myDomain


Edited Tomcat's server.xml (inside the Engine tag)
Code:
<Host name="myDomain.com" appBase="webapps/myApp">
<Context path="" docBase="."/>
</Host>
<Host name="www.myDomain.com" appBase="webapps/myApp">
<Context path="" docBase="."/>
</Host>


This works great. But I don't like to put static files (html, images, videos etc.) into {tomcat home}/webapps/myApp's subfolders instead I'd like to put them the apache webserver's root WWW directory's subdirectories. And I'd like Apache web server to serve these files alone.

How could I do this? So all incoming request will be forwarded to Tomcat except those that ask for a static file.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7294
Location: Germany, Next to Hamburg

PostPosted: Wed 16 Mar '11 2:03    Post subject: Reply with quote

Add an exception to the ProxyPass

e.g.
Code:

ProxyPass /static !
ProxyPass /javascript !
ProxyPass /images !
ProxyPass /another !
Back to top


Reply to topic   Topic: Serving static content with Apache web server and Tomcat View previous topic :: View next topic
Post new topic   Forum Index -> Third-party Modules