If you want 1 server instance serving plain HTML for all your domains,
you can do something like this:
ns_register_proc GET / vhost
ns_register_proc HEAD / vhost
proc vhost {conn ignore} {
set hdrs [ns_conn headers]
set host [string tolower [ns_set iget $hdrs Host]]
set url [ns_conn url]
# do whatever you want to figure out how to map a hostname and url to
# a file ($fspathname) in your file system
ns_returnfile 200 [ns_guesstype $url] $fspathname
}
There is no redirect involved, so whatever the user typed in is what
will stay in their browser address window.
To do the hostname/url -> file mapping for example, you can have an
ns_share/nsv the maps hostnames to a file system directory. If there
is no entry for a hostname, you can display an error page, redirect to
your home page, whatever. Or you can do something simpler like create
a directory and put hostname:port directories underneath that. Then
you wouldn't need a map.
Once you get the basic thing working, you can add more frills, like
checking the url suffix to see if it's .tcl and then using the source
command to run the TCL script, checking for a trailing slash and doing
a directory list (if you want that), etc.
I'd stick with TCL solutions for virtual hosting, esp. in the
beginning. You can do them yourself with very little effort once you
get the hang of it, and make them do cartwheels at your command. If
you get it working and *measure* a performance problem in your TCL
vhost routine, then you can do something about it. We never have.
Good luck!
Jim
www.rubylane.com
>
> Hello,
>
>
> I just installed virtual hosting on my machine (using Aolserver3.3ad13)
> I used Jerry's nsvhr/nsunix config found on his site.
>
> I have 3 sites :
> master.mydomain.com:8080
> sub1.mydomain.com:8081
> sub2.mydomain.com:8082
>
> Redirection works well, but the URL in the browser shows the actual port of
> eiher site (8081 or 8082) instead of 8080.
>
> i.e: query ; http://sub1.mydomain.com:8080/index.html
> response : http://sub1.mydomain.com:8081/index.html
>
> It bother me, because when I go live, I will put master.mydomain.com on
> port 80, and I dont want to see any port in the browser URL for my subsite.
>
> Is it possible to :
> query : http://sub1.mydomain.com:8080/index.html
> and have a response : http://sub1.mydomain.com:8080/index.html
> (same port showing, wich means no port showing when on port 80)
>
> Thx
>