Find the answer to your Linux question:
Results 1 to 2 of 2
Hi everybody, I am looking to see if there is a way to have a dynamic <VirtualHost> directive. What I have is a local development box that I have several ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2005
    Posts
    7

    Dynamic <VirtualHosts>


    Hi everybody, I am looking to see if there is a way to have a dynamic <VirtualHost> directive. What I have is a local development box that I have several subdomains being pointed to from a live production server. Currently I have over 30 subdomains pointing to the development box and I have wanting to rebuild the server and do some updates.

    The way I have it setup now is a line (e.g include conf/sub.domain.com) in the httpd.conf for each subdomain used by the server. In the file sub.domain.com I have the following

    Code:
     
    <VirtualHost 192.168.1.254&#58;80>
        ServerAdmin admin@domain.com
        ServerName sub.domain.com
        DocumentRoot /www/html/sub.domain.com
        ErrorLog /www/logs/sub.domain.com-error_log
        CustomLog /www/logs/sub.domain.com-access_log common
    </VirtualHost>
    *Note the server is behind a firewall therfore the 192. address

    This works fine for each file and a corresponding line in the httpd.conf file. What I want is only one VirtualHost directive and a dynamic way to have the domain be put in place of sub.domain.com.

    Anybody know of a way or ways?

  2. #2
    Just Joined!
    Join Date
    Jan 2005
    Location
    UK
    Posts
    77
    Im not sure there is a way to do this im afraid, although ive never really looked at it like that. If i see it correctly, Apache looks down the list of virtual servers until it finds one that compares with the headers supplied from the users' client (the browser!), hence the warning about old (very old!) browsers in the name based virtual hosts section of the apache manual. SO, you need to have something specified in the ServerName section.

Posting Permissions

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