• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 308
  • Last Modified:

Apache Virtual Hosts problem

I have a dns server set up for http://dirtywerm.com, what I want to do now is set up apache virtual hosting.

Everytime I try to enable the virtual hosting everything but localhost stops working.

I'm not sure if the problem is to do with my dns server or if i'm doing something wrong with apache.

So what I'm trying to do is make sure that my domain name works both locally and externally using virtual hosts.
0
dirtywerm
Asked:
dirtywerm
  • 5
  • 2
1 Solution
 
dirtywermAuthor Commented:
Also I am using apache 2

When I try to enable virtual hosting I uncomment the following line:
#Include conf/vhosts/vhosts.conf


Here is vhosts.conf:

NameVirtualHost *
<VirtualHost *>
ServerName dirtywerm.com
DocumentRoot /var/www/dirtywerm/htdocs
</VirtualHost>

/var/www/dirtywerm is just a copy of /var/www/localhost


0
 
jlevieCommented:
It would most helpful to know what version of Apache you are using.

For a 2.x version of Apache you'd configure virtual hosts by having something along the lines of:

NameVirtualHost *:80

<VirtualHost *:80>
  ServerName "www.dirtywerm.com"
  ServerAlias "dirtywerm.com"
  ServerAdmin "webmaster@dirtywerm.com"
  DocumentRoot "/home/webs/www.dirtywerm.com/htdocs"
  <Directory />
    AllowOverride AuthConfig
    Options FollowSymLinks Multiviews
    Order allow,deny
    Allow from all
  </Directory>
   ScriptAlias /cgi-bin/ "/home/webs/www.dirtywerm.com/cgi-bin/"
  <Directory "/home/webs/www.dirtywerm.com/cgi-bin">
    AllowOverride AuthConfig
    Options ExecCGI
    Order allow,deny
    Allow from all
  </Directory>
  CustomLog "/home/webs/www.dirtywerm.com/logs/access_log" combined
  ErrorLog "/home/webs/www.dirtywerm.com/logs/error_log"
</VirtualHost>

with httpd.conf (with the paths adjusted for local conditions). To have the site work internally and externally you need to ensure that the DNS views for each properly resolve the anme to the appropriate IP. That means that from inside you get an inside IP for the name and from outside you get an outside IP.
0
 
dirtywermAuthor Commented:
Ok, the virtual host is working now but how do I set up bind 9 to working differently internally and externally?
0
[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

 
dirtywermAuthor Commented:
Here is my current named.conf

options {
        directory "/var/bind";

        listen-on-v6 { none; };
        listen-on { 127.0.0.1; 192.168.0.100; };

        pid-file "/var/run/named/named.pid";
};

zone "." IN {
        type hint;
        file "named.ca";
};

zone "localhost" IN {
        type master;
        file "pri/localhost.zone";
        allow-update { none; };
        notify no;
};

zone "127.in-addr.arpa" IN {
        type master;
        file "pri/127.zone";
        allow-update { none; };
        notify no;
};

zone "dirtywerm.com" IN {
        type master;
        file "pri/dirtywerm.zone";
        allow-update { none; };
        notify no;
};

zone "b-train.com" IN {
        type master;
        file "pri/btrain.zone";
        allow-update { none; };
        notify no;
};

0
 
jlevieCommented:
What version of Bind are you using? And is this copy of Bind the only name server for the domain?
0
 
dirtywermAuthor Commented:
For now this is the only name server. I was making sure my set up was right. I am using bind 9.
0
 
dirtywermAuthor Commented:
Would this be the correct way to set up the views?

options {
        directory "/var/bind";

        listen-on-v6 { none; };
        listen-on { 127.0.0.1; 192.168.0.100; };

        pid-file "/var/run/named/named.pid";
};

view "internal" {

        match-clients { localnets; };
        recursion yes;

        zone "." IN {
                type hint;
                file "named.ca";
        };

        zone "localhost" IN {
                type master;
                file "pri/localhost.zone";
                allow-update { none; };
                notify no;
        };

        zone "127.in-addr.arpa" IN {
                type master;
                file "pri/127.zone";
                allow-update { none; };
                notify no;
        };

        zone "dirtywerm.com" IN {
                type master;
                file "pri/dirtywerm.internal";
                allow-update { none; };
                notify no;
        };

        zone "b-train.com" IN {
                type master;
                file "pri/btrain.internal";
                allow-update { none; };
                notify no;
        };
};

view "external" {
        match-clients { any; };
        recursion no;

        zone "dirtywerm.com" IN {
                type master;
                file "pri/dirtywerm.external";
                allow-update { none; };
                notify no;
        };

        zone "b-train.com" IN {
                type master;
                file "pri/btrain.external";
                allow-update { none; };
                notify no;
        };
};

0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now