Forum Moderators: phranque

Message Too Old, No Replies

Multiple Virtual Host Issue

         

tomcat2000

1:24 pm on May 8, 2012 (gmt 0)

10+ Year Member



I have Apache HTTPD running on a server with two private IP addresses. There are two public IP addresses and domains NAT'd to the two private IP addresses.

So,

public IP address 1 (public www.domain1.com) -> private IP address 1 (10.10.10.11)

public IP address 2 (public www.domain2.com) -> private IP address 2 (10.10.10.12)


The problem I'm having is that if I type in [domain2.com...] or [domain2.com...] in a browser, I always end up at [domain1.com...]

Apache is basically set up to proxy requests to two application servers (10.10.20.11 and 10.10.20.12 below). Redirection from http to https is working fine. Proxying is working fine as well, but only for domain1.com.


Apache is set up as follows:

Listen 10.10.10.11:80
Listen 10.10.10.12:80
Listen 10.10.10.11:443
Listen 10.10.10.12:443

NameVirtualHost 10.10.10.11:80
NameVirtualHost 10.10.10.12:80
<VirtualHost 10.10.10.11:80>
DocumentRoot "/var/www/html"
ServerName www.domain1.com:80
Redirect / [domain1.com...]
</VirtualHost>

<VirtualHost 10.10.10.12:80>
DocumentRoot "/var/www/html"
ServerName www.domain2.com:80
Redirect / [domain2.com...]
</VirtualHost>

NameVirtualHost 10.10.10.11:443
NameVirtualHost 10.10.10.12:443



<VirtualHost 10.10.10.11:443>

ServerName www.domain1.com:443

# SSL stuff (certs, etc.)

SSLProxyEngine On

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

ProxyPreserveHost On
ProxyRequests Off
ProxyVia On

# Proxy requests to application server 10.10.20.11

ProxyPass / [10.10.20.11:8443...]
ProxyPassReverse / [10.10.20.11:8443...]

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{HTTPS} off
RewriteRule (.*) [%{HTTP_HOST}%{REQUEST_URI}...] [L,R=301]

ProxyPassReverseCookiePath / /

</VirtualHost>



<VirtualHost 10.10.10.12:443>

ServerName www.domain2.com:443

# SSL stuff (certs, etc.)

SSLProxyEngine On

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

ProxyRequests Off

ProxyVia On

# Proxy requests to application server 10.10.20.12

ProxyPass / [10.10.20.12:8443...]
ProxyPassReverse / [10.10.20.12:8443...]

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{HTTPS} off
RewriteRule (.*) [%{HTTP_HOST}%{REQUEST_URI}...] [L,R=301]

ProxyPassReverseCookiePath / /

</VirtualHost>


I've tried some things but haven't been able to figure this out yet. Any help would be most appreciated.