Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Junior Member
    Join Date
    Sep 2003
    Posts
    8

    Default VirtualHost in httpd.conf?

    I'm curious to hear if anybody with a dedicated IP address has tried to set up name-based virtual hosting by adding something like the following to their httpd.conf:

    NameVirtualHost *

    <VirtualHost *>
    ServerName www.domain.tld
    DocumentRoot /www/domain
    </VirtualHost>

    <VirtualHost *>
    ServerName www.otherdomain.tld
    DocumentRoot /www/otherdomain
    </VirtualHost>

    When doing this, must the preexisting domain (www.domain.tld in this example) into a VirtualHost element? Or can one leave httpd.conf the way it is, and simply add a single VirtualHost element for the additional domain (www.otherdomain.tld in this example)?

    I've already got DNS appropriately configured, with both of my domains resolving to my dedicated IP at WestHost. Just wondering if there are any httpd.conf gurus who can clarify the Apache configuration issue for me.

    Thanks!
    Adrian

  2. #2
    Moderator wildjokerdesign's Avatar
    Join Date
    Jun 2003
    Location
    Kansas City Mo
    Posts
    5,720

    Default

    When you add a domain via your Site Manager it adds what your are speaking of above to your httpd.conf with a few diffrences.

    ServerName otherdomain.com
    ServerAlias www.otherdomain.com
    DocumentRoot depends on what you enter

    Does that answer your question?

    Shawn
    Shawn
    Please remember your charity of choice: http://www.redcross.org

    Handy Links: wildjokerdesign.net | Plain Text Editors: EditPlus | Crimson

  3. #3
    Junior Member
    Join Date
    Sep 2003
    Posts
    8

    Default VirtualHost and "simple name-based vhosting"

    Thanks for the info... I decided to experiment with httpd.conf and it seems like I only need to create a single VirtualHost leaving the "main" configuration to catch the rest of the requests. I added something like this:

    NameVirtualHost *
    <VirtualHost *:8080>
    ServerName www.otherdomain.tld
    DocumentRoot /www/otherdomain
    </VirtualHost>

    I don't want to specify port 8080, but I can only get the VirtualHost to catch requests if I specify that it is on port 8080. The server switches between my main and virtual server depending on which port I specify:

    www.domain.tld --> main
    www.domain.tld:80 --> main
    www.otherdomain.tld --> main
    www.otherdomain.tld:80 --> main
    www.domain.tld:8080 --> virtual
    www.otherdomain.tld:8080 --> virtual

    Can't seem to get it to switch on the basis of the request's "Host:" header. I guess that the configuration for the "main" server is somehow matching *any* request to port 80 on my dedicated IP address, no matter what the "Host:" header says, but I don't know what aspect of the "main" configuration would be responsible for that behavior.

    Adrian

  4. #4
    Moderator wildjokerdesign's Avatar
    Join Date
    Jun 2003
    Location
    Kansas City Mo
    Posts
    5,720

    Default

    I have you checked this page out yet http://httpd.apache.org/docs/vhosts/ ? It sounds like maybe you are a bit more knowlegable when it comes to this area then I am. I am trying to muddel through and learn as much as I can and just how much control we really have with this VDS and Virtual Host thing.

    I am working with some other users to figure out if with the virtual host you can keep the thierdomain.com showing up after a browser goes to a second directory in the thierdomain area i.e. if you had thierdomain.com/somedirectory/page.html it show in the address as yourdomain.com/somedirectory/page.html. This may be a seprate issue compleatly like I say I am just muddeling through.

    Shawn

    P.S. How did you edit the httpd.conf... via SSH or did you download via FTP and the uplaod it again.
    Shawn
    Please remember your charity of choice: http://www.redcross.org

    Handy Links: wildjokerdesign.net | Plain Text Editors: EditPlus | Crimson

  5. #5
    Senior Member jalal's Avatar
    Join Date
    May 2003
    Location
    Germany
    Posts
    1,377

    Default

    Adrian

    When you put:
    NameVirtualHost *
    <VirtualHost *:8080>
    ServerName www.otherdomain.tld
    DocumentRoot /www/otherdomain
    </VirtualHost>

    you are telling apache that anything on port 8080 is to be mapped to the 'otherdomain.tld'. Otherwise the default is to pass all connections to 'domain.tld'

    You need something like this:

    <VirtualHost otherdomain.tld>
    ServerName www.otherdomain.tld
    DocumentRoot /www/otherdomain
    </VirtualHost>

  6. #6
    Junior Member
    Join Date
    Sep 2003
    Posts
    8

    Default

    Hi Jalal,

    Yes, I understand what you're saying, but I already tried the sort of VirtualHost config you've suggesting (and even retried it again after reading your posting) and it doesn't work. It seems straightforward enough to configure a named vhost as per your example (or the various FAQs on the web), but it just doesn't work for me here -- probably because of something specified in the "main" server config.

    My point with the port 8080 example was to show that it is indeed possible to configure *some sort of virtual host*. I don't actually want my vhost on port 8080, but at least I've convinced myself that vhosts in general are possible.

    Adrian

  7. #7
    Junior Member
    Join Date
    Sep 2003
    Posts
    8

    Default

    Quote Originally Posted by wildjokerdesign
    have you checked this page out yet http://httpd.apache.org/docs/vhosts/ ?
    Yep, I've read a number of vhost FAQs. It all seems pretty simple, but I must be missing some key point.

    Quote Originally Posted by wildjokerdesign
    How did you edit the httpd.conf... via SSH or did you download via FTP and the uplaod it again.
    Since the changes I'm making are minor, I log on via SSH and then use "pico" to edit the file. Pico probably seems like a strange choice, but I got used to it many years ago when I used Pine for email. If I had to do more extensive editing, I suppose I'd FTP the file to my Windows machine and use UltraEdit.

  8. #8
    Senior Member jalal's Avatar
    Join Date
    May 2003
    Location
    Germany
    Posts
    1,377

    Default

    Hi Adrian

    Pity, its *supposed* to work like that

    Dragging out the Apache manual here, I notice that they put the IP address in the NameVirtualHost directive, like so:
    =========
    NameVirtualHost 69.36.162.101
    <VirtualHost domain.tld>
    ServerName www.domain.tld
    DocumentRoot /www
    </VirtualHost>
    <VirtualHost otherdomain.tld>
    ServerName www.otherdomain.tld
    DocumentRoot /www/otherdomain
    </VirtualHost>
    =========

    Maybe worth a try?

  9. #9
    Member
    Join Date
    Aug 2003
    Location
    Sacramento California
    Posts
    64

    Default Re: VirtualHost in httpd.conf?

    Quote Originally Posted by adrianboyko
    I'm curious to hear if anybody with a dedicated IP address has tried to set up name-based virtual hosting by adding something like the following to their httpd.conf:

    NameVirtualHost *

    <VirtualHost *>
    ServerName www.domain.tld
    DocumentRoot /www/domain
    </VirtualHost>

    <VirtualHost *>
    ServerName www.otherdomain.tld
    DocumentRoot /www/otherdomain
    </VirtualHost>

    When doing this, must the preexisting domain (www.domain.tld in this example) into a VirtualHost element? Or can one leave httpd.conf the way it is, and simply add a single VirtualHost element for the additional domain (www.otherdomain.tld in this example)?

    I've already got DNS appropriately configured, with both of my domains resolving to my dedicated IP at WestHost. Just wondering if there are any httpd.conf gurus who can clarify the Apache configuration issue for me.

    Thanks!
    Adrian
    I have tried to setup virtualhosts and I couldn't get it to work. I am a novice, but I have set them up up Windows2000 & Apache. If you look in the conf, file under your domain name, there is a listing at line number 429 "group vuser". I think this must refer to the additional domain name pointed to your account. I have search for this file and couldn't find it. It may refer to a master server file somewhere? I am not sure Apache works the same under this VDS system. I think you will also have to add the domain names under ServerName if it will let you.

    I have not tried to many changes because of all the current problems under WH2. Right now I am happy having a site that is up

    Charlie

  10. #10
    Junior Member
    Join Date
    Sep 2003
    Posts
    8

    Default Re: VirtualHost in httpd.conf?

    Quote Originally Posted by REC-WH
    If you look in the conf, file under your domain name, there is a listing at line number 429 "group vuser". I think this must refer to the additional domain name pointed to your account. I have search for this file and couldn't find it. It may refer to a master server file somewhere?
    "vuser" is just the name of the group that your login account belongs to. File permissions in *nix are based on your userid and groupid. If this is new to you, try looking for "group user permissions tutorial" on Google.

    The line you mention in httpd.conf tells the server what user and group it should run as. Since file access permissions are based on user and group, this will affect what your server can and can't access while running.

    At least that's the way I understand it.

Similar Threads

  1. OK to use mod_deflate in httpd.conf?
    By WilliamSiddall in forum General Discussion
    Replies: 1
    Last Post: 10-16-2007, 02:37 PM
  2. httpd.conf Questions
    By Lulu in forum General Discussion
    Replies: 2
    Last Post: 04-02-2007, 09:40 PM
  3. httpd.conf
    By Barbara Moore in forum Account Maintenance
    Replies: 5
    Last Post: 12-19-2006, 04:34 AM
  4. Apache VirtualHost trouble
    By art887 in forum General Discussion
    Replies: 4
    Last Post: 09-19-2005, 08:04 AM
  5. Trying to block hotlinking with .htaccess or httpd.conf
    By cgmsys in forum General Discussion
    Replies: 2
    Last Post: 11-14-2004, 02:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •