Simple functionality improvement for vhosts package



  • the vhost package should allow the entry of blank ("") hostnames. This would allow for the creation of default web servers that would respond to any requests on a given port.  As in …

    #the regex method isn't working
    #$HTTP["host"] =~ "(^|.)host01.com$" {
    #      server.document-root        = "/usr/local/vhosts/host01"
    #}

    $SERVER["socket"] == ":8080" {
                    server.document-root        = "/usr/local/vhosts/fusionpbx"
    }

    error-handler for status 404

    #server.error-handler-404  = "/error-handler.html"
    #server.error-handler-404  = "/error-handler.php"

    the current code creates the following which is in error
    $SERVER["socket"] == ":8080" {
        $HTTP["host" == "" {
                    server.document-root        = "/usr/local/vhosts/fusionpbx"
        }
    }

    here is a patch which addresses this issue and fixes it.

    –------
    --- vhosts.inc 2011-05-05 04:26:17.000000000 +0000
    +++ vhosts.inc.orig 2011-05-05 04:22:59.000000000 +0000
    @@ -325,9 +325,7 @@
    $tmp .= "$SERVER["socket"] == "".$ipaddress.":".$port."" {\n";
    }

    • if ( $host != "" ) {
    • $tmp .= " $HTTP["host"] == "".$host."" {\n";
    • }
    • $tmp .= " $HTTP["host"] == "".$host."" {\n";
      $tmp .= " server.document-root        = "/usr/local/vhosts/".$directory.""\n";

    //enable ssl if the cert and key were both provided
    @@ -340,7 +338,7 @@
    $tmp .= " ssl.engine = "enable"\n";
    unset($pem_file);
    }

    • if (count($vhostarray_http) > 0 && $host != "" ) {
    • if (count($vhostarray_http) > 0) {
      $tmp .= " }\n";
      }

    –------

    thanks,

    --luis


Locked