Virtual Hosts

http://naviserver.sourceforge.net/ns_logobig.gif

MainSource Code Downloads API Documentation Mailing Lists Bugs Developers


Virtual Hosts

Configuration required for NaviServer to listen on the same port for several hostnames (with logs) as per HTTP 1.1.

set        package                   naviserver

# Absolute path to the installation directory
set        homedir                   /usr/lib/${package}

# Log directories (access log, error log, pidfile)
set        logdir                    /var/log/${package}
set        piddir                    /var/run/${package}

# Name/description of the virtual server
set        servername1               alpha
set        servername2               beta

# The hostname, address and port for nssock should be set to actual values.
set        main_address              192.168.1.128
set        port                      80

################################################################
# Modules
################################################################
ns_section      "ns/modules"
   ns_param     nssock               ${homedir}/bin/nssock.so

ns_section      "ns/server/$servername1/modules"
   ns_param     nslog                ${homedir}/bin/nslog.so

ns_section      "ns/server/$servername2/modules"
   ns_param     nslog                ${homedir}/bin/nslog.so


################################################################
# Global Parameters
################################################################
ns_section      "ns/parameters"
   # Home directory for the server, it will be resolved automaticlaly if not specified
   ns_param     home                 $homedir

   # Main server log file
   ns_param     serverlog            ${logdir}/virtual-hosts.log

   # Pid file of the server process
   ns_param     pidfile              ${piddir}/virtual-hosts.pid


################################################################
# Servers
################################################################
ns_section      "ns/servers"
   ns_param     $servername1         "Naviserver $servername1"
   ns_param     $servername2         "Naviserver $servername2"


################################################################
# nslog config
################################################################
ns_section      "ns/server/${servername1}/module/nslog"
   # Name to the log file
   ns_param     file                 ${logdir}/${servername1}-access.log

ns_section      "ns/server/${servername2}/module/nslog"
   # Name to the log file
   ns_param     file                 ${logdir}/${servername2}-access.log


################################################################
# nssock config
################################################################
ns_section      "ns/module/nssock"
   ns_param     port                 $port
   ns_param     address              $main_address
   ns_param     defaultserver        $servername1

ns_section      "ns/module/nssock/servers"
   ns_param     $servername1         alpha.co.uk
   ns_param     $servername2         beta.co.uk


################################################################
# Fastpath
################################################################
ns_section      "ns/server/${servername1}/fastpath"

   # Defines absolute or relative to serverdir directory where all html/adp pages are located
   ns_param     pagedir              /var/www/alpha.co.uk/

   # Directory index/default page to look for.
   ns_param     directoryfile        "index.adp index.html index.htm"


ns_section      "ns/server/${servername2}/fastpath"
   ns_param     pagedir              /var/www/beta.co.uk/ 
   ns_param     directoryfile        "index.html index.htm"