Solved

Apache Virtual Hosts problem

Posted on 2004-11-01
239 Views
Last Modified: 2013-11-18
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
Question by:dirtywerm
    7 Comments
     

    Author Comment

    by:dirtywerm
    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
     
    LVL 40

    Accepted Solution

    by:
    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
     

    Author Comment

    by:dirtywerm
    Ok, the virtual host is working now but how do I set up bind 9 to working differently internally and externally?
    0
     

    Author Comment

    by:dirtywerm
    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
     
    LVL 40

    Expert Comment

    by:jlevie
    What version of Bind are you using? And is this copy of Bind the only name server for the domain?
    0
     

    Author Comment

    by:dirtywerm
    For now this is the only name server. I was making sure my set up was right. I am using bind 9.
    0
     

    Author Comment

    by:dirtywerm
    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
    Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
    Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    934 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now