mixelogj
asked on
DNS and virtual web servers
hello,
This is what i want to do in a Linux RedHat 6.0 shell box:
The shell contains two DNS entries already ( two domains with their sub-domains and the ips to which they point ). I want to add another dns entry which will point to the same ip as the other two BUT when called for web pages it will not use the default document root of apache as the other two but will point to another document root. That is to say, if the domain i want to add is new.com and one of the existing ones os old.com : when old.com is called by a web browser it will point to /home/httpd/html/ but when new.com is called by a web browser it will point to /home/httpd/html/new/ Someone told me that i need to create a virtual web server, so the question is how to do all this. I appreciate your help.
Solutions via Linuxconf prefered because this is the only utility which i am sure is stable and safe 100%
Thanks,
Mixelogj
This is what i want to do in a Linux RedHat 6.0 shell box:
The shell contains two DNS entries already ( two domains with their sub-domains and the ips to which they point ). I want to add another dns entry which will point to the same ip as the other two BUT when called for web pages it will not use the default document root of apache as the other two but will point to another document root. That is to say, if the domain i want to add is new.com and one of the existing ones os old.com : when old.com is called by a web browser it will point to /home/httpd/html/ but when new.com is called by a web browser it will point to /home/httpd/html/new/ Someone told me that i need to create a virtual web server, so the question is how to do all this. I appreciate your help.
Solutions via Linuxconf prefered because this is the only utility which i am sure is stable and safe 100%
Thanks,
Mixelogj
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Basically all that's needed, per the docs, is to tell Apache it's using named virtual hosts and to define the virtual host. An example from one of my Apache installations looks like:
NameVirtualHost 192.168.0.3
:
## Plaintext Virtual Host
<VirtualHost 192.168.0.3:8080>
ServerName docs.dynetics.com
ServerAdmin Jim.Levie@dynetics.com
DocumentRoot "/opt/Apache/htdocs/docs"
<Directory />
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Apache does need to be listening at the global level on the port (even if there are no "servers" defined at the global level). This one is configured to listen on 80, 8080, & 443 and all of its server instances are virtual.
NameVirtualHost 192.168.0.3
:
## Plaintext Virtual Host
<VirtualHost 192.168.0.3:8080>
ServerName docs.dynetics.com
ServerAdmin Jim.Levie@dynetics.com
DocumentRoot "/opt/Apache/htdocs/docs"
<Directory />
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Apache does need to be listening at the global level on the port (even if there are no "servers" defined at the global level). This one is configured to listen on 80, 8080, & 443 and all of its server instances are virtual.
ASKER
so in my case, if new.com should be the virtual host the form should be:
NameVirtualHost new.com
:
## Plaintext Virtual Host
<VirtualHost new.com>
ServerName newest(any name)
ServerAdmin me@new.com
DocumentRoot "/home/httpd/html/new/"
<Directory />
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
right?
NameVirtualHost new.com
:
## Plaintext Virtual Host
<VirtualHost new.com>
ServerName newest(any name)
ServerAdmin me@new.com
DocumentRoot "/home/httpd/html/new/"
<Directory />
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
right?
Not quite... In my example the system Apache is running has the DNS A records in the dynetics.com domain of:
mystic IN A 192.168.0.3
docs IN CNAME mystic.dynetics.com.
I tell Apache that I'll be using named virtual hosts whose connections to the server will be coming in on IP 192.168.0.3 via:
NameVirtualHost 192.168.0.3
"<VirtualHost 192.168.0.3:8080>" declares a new virtual host listening on 8080 in this case, and "ServerName docs.dynetics.com" says that this virtual server will respond only to URL's that look like "http://docs.dynetics.com".
mystic IN A 192.168.0.3
docs IN CNAME mystic.dynetics.com.
I tell Apache that I'll be using named virtual hosts whose connections to the server will be coming in on IP 192.168.0.3 via:
NameVirtualHost 192.168.0.3
"<VirtualHost 192.168.0.3:8080>" declares a new virtual host listening on 8080 in this case, and "ServerName docs.dynetics.com" says that this virtual server will respond only to URL's that look like "http://docs.dynetics.com".
Followup to the last comment (I accidentally hit Submit).
In your case you should have a DNS definition that points "new.com" at the base IP of your server and you'd put that into ServerName, i.e., "ServerName new.com"
The relevant DNS records from the two zone files would look something like:
base (or real zone):
$ORIGIN base-domain.com
server IN A 192.168.0.1
virtual domain zone:
$ORIGIN new.com
www IN A 192.168.0.1
Note that you don't need or want a reverse addr definition for the virtual hosts, but that you do need one for the base server
In your case you should have a DNS definition that points "new.com" at the base IP of your server and you'd put that into ServerName, i.e., "ServerName new.com"
The relevant DNS records from the two zone files would look something like:
base (or real zone):
$ORIGIN base-domain.com
server IN A 192.168.0.1
virtual domain zone:
$ORIGIN new.com
www IN A 192.168.0.1
Note that you don't need or want a reverse addr definition for the virtual hosts, but that you do need one for the base server
ASKER