Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Update Thanks to Bill and crb's answers, I believe I have it working.

xxx@host:/etc/apache2/sites-available$ apache2ctl -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
         default server default (/etc/apache2/sites-enabled/000-default:4)
         port 80 namevhost default (/etc/apache2/sites-enabled/000-default:4)
         port 80 namevhost www.123acme.com (/etc/apache2/sites-enabled/www.123acme.com:4)
Syntax OK

Now www.123acme.com will resolve to the proper VirtualHost served by Apache from /var/www, while everything else if proxied to Jetty.


I have an Apache2 instance on port 80 and a Jetty app server running on 8080. I would like the Apache instance to server up a VirtualHost, let's say www.acme.com, and to send all other traffic to the Jetty instance.

So far I have sites-available/jetty which contains

ProxyRequests Off

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

ProxyPass / http://localhost:8080/
ProxyPreserveHost On
ProxyStatus On

with the goal of first getting everything to proxy to Jetty. This seems to be working okay so far.

So from this point, how would I got about configuring the various VirtualHosts which don't get proxied?

Just to reiterate:

-Typing www.acme.com should resolve to a traditional VirtualHost sitting in /var/www and served by Apache2 from the config in sites-enabled/acme.com

-Typing anything else should get forwarded to the Jetty instance running on 8080

share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

The first vhost in the file (or that is included) is the default, and is where it will fall through to. Thus, just make the first vhost be the proxy, then a second that is www.acme.com.

share|improve this answer
add comment

If you don't have a VirtualHost definition match (based on ServerName/ServerAlias), Apache will serve your request with the first VirtualHost. (See the docs).

Set up a virtual host with a name like 000-first, and put your ProxyPass configuration in that. They are included in directory sort order.

share|improve this answer
    
Just beat me :( –  Bill Weiss Dec 8 '09 at 20:36
    
So I renamed the "jetty" file to "default" tossing the original one that comes with apache. I then made a www.test.com file, published it via a2ensite, and confirmed that sites-enabled contained "000-default" and "www.test.com". I then modified my host file (on Windows) with an entry mapping www.test.com to my server. Unfortunately it's still rendering through the proxy/Jetty. –  rcampbell Dec 8 '09 at 21:23
    
Run apache2ctl -S and see what the output is. Make sure it sees two vhosts, and that the right one is marked as "default". –  Bill Weiss Dec 8 '09 at 23:11
add comment

I would go about this by creating two VirtualNost.

The first VirtualHost, the default one, would contain the ProxyPass settings. Based on your file names it looks as if you are running Debian or Ubuntu? In that case we are talking about /etc/apache2/sites-enabled/000-default (aka: /etc/apache2/sites-available/default).

Then the second VirtualHost would specificly specify www.acme.com as its ServerName, and serve up the content of /var/www.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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