I have two websites; OLDSITE and NEWSITE. The OLDSITE has 120 IP Address that it has with it, and the NEWSITE had 5. I want to be able to separate everything from OLDSITE and NEWSITE so they are not tied together but use them on the same linux computer. My current apache setup is this:
Listen 80
NameVirtualHost *
<VirtualHost *>
ServerName oldsite.com
ServerAdmin
[email protected]
DocumentRoot /var/www/
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^.]+)\.oldsite\.com$
RewriteCond /home/%1/ -d
RewriteRule ^(.+) %{HTTP_HOST}$1
RewriteRule ^([^.]+)\.oldsite\.com/media/(.*) /home/$1/dir/media/$2
RewriteRule ^([^.]+)\.oldsite\.com/(.*) /home/$1/www/$2
</VirtualHost>
<VirtualHost newsite.com>
ServerName newsite.com
ServerAdmin
[email protected]
DocumentRoot /var/newsite/
<Directory /var/newsite/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^.]+)\.newsite\.com$
RewriteCond /home/%1/ -d
RewriteRule ^(.+) %{HTTP_HOST}$1
RewriteRule ^([^.]+)\.newsite\.com/media/(.*) /home/$1/dir/media/$2
RewriteRule ^([^.]+)\.newsite\.com/(.*) /home/$1/www/$2
</VirtualHost>
<VirtualHost *>
ServerName panel.oldsite.com
ProxyPass / http://panel.oldsite.com:10000/
ProxyPassReverse / http://panel.oldsite.com:10000/
<Proxy *>
allow from all
</Proxy>
</VirtualHost>
<VirtualHost *>
ServerName panel.newsite.com
ProxyPass / http://panel.newsite.com:10000/
ProxyPassReverse / http://panel.newsite.com:10000/
<Proxy *>
allow from all
</Proxy>
</VirtualHost>
I want to be able to access anything that is newsite.com and have it go to the /var/newsite unless their is a home directory...and then if its panel.newsite.com I want it to automatically do a proxypass to panel.newsite.com:10000... With this setup, it works perfect for oldsite.com.... both the proxy and the webpages... However, having the Virtualhost set to newsite.com renders the proxypass worthless. If I change the Virtualhost for the newsite.com to a wildcard, the proxypass will work but anything thats a subdomain of newsite.com won't work. so newsite.com will work, but www.newsite.com will not load correctly.
I am assuming that when everything is wildcarded, then the ServerName somewhat acts like a RewriteCond and actually just applies the stuff to that URL. It uses the Virtualhost * (oldsite.com) and lets ANYTHING.oldsite.com work, but the second virtualhost * (newsite.com) only newsite.com will work... www.newsite.com will not. If I change the order of them, the opposite is true. So apparently it doesn't like me using 2
wildcards...
I tried just making the Servername *.newsite.com .......but that would be too easy. I am not sure what I can do to do what I want? Perhaps I should make the ProxyPass included in the VirtualHosts and use something like:
RewriteCond %{HTTP_HOST} ^panel\.newsite\.com$ [NC]
RewriteRule ^(.*)$ http://panel.newsite.com:10000/ [P]
ProxyPassReverse / http://panel.newsite.com:10000/
but that doesnt seem to want to login to webmin, it loads the login page but isnt working how the ProxyPass & ProxyPassReverse does.