Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Package vhosts: allow Regex

    Scheduled Pinned Locked Moved pfSense Packages
    1 Posts 1 Posters 1.5k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      Reiner030
      last edited by

      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. http://192.168.1.1/wpad.dat resolved (or a picture for SQuiD) ?
      I don't know why but the hostname can't be 192.168.1.1 …

      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/vhosts.inc.orig	2013-12-01 19:11:58.000000000 -0200
      +++ /usr/local/pkg/vhosts.inc	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.

      Bests

      1 Reply Last reply Reply Quote 0
      • First post
        Last post
      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.