Package vhosts: allow Regex

  • Hi,

    (little longer because I didn't found any entries for "vhosts" in the forum… so it can help other as little documentation, too).

    I need for wpad.dat and error image for SQuiD an easy solution on an external firewall...
    pfSense uses default https rewriting and therefore the content wouldn't be available per default because pfSense uses a selfsigned cert.

    The easy solution seemed the vHosts package with offers an easy alternative on http port after activating in
    System => Advanced => Admin Access the option "Disable webConfigurator-redirect rule" and letting above HTTPS protocol active.

    The first problem was finding out that deeper reading would be good ;)
    Because I accidently added the prefix in the offered long input field again:

    This vHosts directory is located in /usr/local/vhosts. The default directory is the host name.
    example: vhost01.local

    => only vhost01.local in this example expands to /usr/local/vhosts/vhosts01.local in correct way.

    2nd was the hostname interpretation… it fits only exact hostnames like "wpad".
    But what if there is no request http://wpad/wpad.dat but for instance http://wpad.local/wpad.dat  ?
    And what happens if I need e.g. resolved (or a picture for SQuiD) ?
    I don't know why but the hostname can't be …

    After some testing I found out that the comment "regex didn't work" is not correct...
    I can match without problems "." or "^.$" or other rules…
    => so it would be nice to fix this globally for all users

    --- /usr/local/pkg/	2013-12-01 19:11:58.000000000 -0200
    +++ /usr/local/pkg/	2013-12-02 20:27:21.000000000 -0200
    @@ -324,7 +324,7 @@
     						$tmp .= "\$SERVER[\"socket\"] == \"".$ipaddress.":".$port."\" {\n";
    -					$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

    BTW: I uses package filer to let create wpad.dat, wpad.da and proxy.pac in this vhost folder; permission 644.


Log in to reply