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.

I'm trying to set up a new virtual host newsletter.mydomain.com.

I'm also using mod_proxy to route all HTTP traffic to my application server (with the IP of 1.1.1.1).

mod_proxy works great but I'm having a real hard trouble setting up the virtual host:

When I try browsing my VHOST, all I get is my main website (instead, for instance, the DocumentRoot i've set to it, or on another try - a ProxyPass declaration that should route traffic)

Here's a brief snippet of my httpd.conf file

ServerRoot "C:/xampp/apache"
Listen 80

NameVirtualHost _default_:80

ServerAdmin postmaster@localhost

ServerName www.mydomain.com:80

DocumentRoot "C:/xampp/htdocs"

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>


<VirtualHost _default_:80>
    ServerName newsletter.mydomain.com
    ProxyPreserveHost On
    ProxyPass / http://1.1.1.1:8080/Newsletter/
    ProxyPassReverse / http://1.1.1.1:8080/Newsletter/
</VirtualHost> 

ProxyPass / http://1.1.1.1/
ProxyPassReverse / http://1.1.1.1/

Main website works gr8 - Virtual host - de nada! any ideas on this issue? (Using Windows 2008 server R2)

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Change _default_:80 to *:80 in both places. The _default_ clause is specifically not used for NameVirtualHost routed VHosts.

However, this still won't work as you expect. As soon as you declare *:80 a NameVirtualHost, your "default" site will never be displayed. (per: http://httpd.apache.org/docs/2.2/mod/core.html#virtualhost)

What you want is something more like this:

ServerRoot "C:/xampp/apache"
Listen 80

# Route all traffic based on Host: header
NameVirtualHost *:80

ServerAdmin postmaster@localhost

ServerName www.mydomain.com:80

# This will never be used:
DocumentRoot "C:/xampp/htdocs"

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

# All non-matching Host: headers use the first VirtualHost:
<VirtualHost *:80>
    ServerName mydomain.com
    ServerAlias www.mydomain.com

    DocumentRoot "C:/xampp/htdocs"
    ProxyPass / http://1.1.1.1/
    ProxyPassReverse / http://1.1.1.1/
</VirtualHost>

# Specific VirtualHost for "newsletter.mydomain.com":
<VirtualHost *:80>
    ServerName newsletter.mydomain.com

    ProxyPreserveHost On
    ProxyPass / http://1.1.1.1:8080/Newsletter/
    ProxyPassReverse / http://1.1.1.1:8080/Newsletter/
</VirtualHost> 
share|improve this answer
    
Tested that - no luck –  Shai Mar 19 '12 at 10:58
    
@Shai, I update with some new information after posting my initial one-liner. –  Kyle Smith Mar 19 '12 at 11:04
    
I got it solved a few minutes ago, your answer matches the solution I've come up with. Thanks! –  Shai Mar 19 '12 at 11:11

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.