For virtual hosting I use this wrapper for ns_conn function:
rename ns_conn _ns_conn
proc ns_conn {args} {
set host [string tolower [ns_set get [ns_conn headers] Host]]
if {[string match [lindex $args 0] "host"]} {
regexp {[^:]+} $host host
return $host
} elseif {[string match [lindex $args 0] "server"]} {
regexp {[^:\.]+} $host host
return $host
} elseif {[string match [lindex $args 0] "port"]} {
if { [regexp {:(\d+)} $host str port] == 1 } {
return $port
}
return
} elseif {[string match [lindex $args 0] "protocol"]} {
if {[string equal [ns_set get [ns_conn headers]
"X-Forwarded-Proto"] "https"]} {
return https
}
return http
} elseif {[string match [lindex $args 0] "location"]} {
return [ns_conn protocol]://$host
} else {
return [_ns_conn {*}$args]
}
}
Reverse-proxy (HAProxy,Pound,etc.) is adding headers X-Forwarded-Proto for
https connections.
2011/2/3 Janine Ohmer <[email protected]>
> I'm moving some sites onto an Amazon EC2 instance, which has only one IP
> address, so I'm using nginx to make this work. The websites (both Apache
> and AOLserver) are running on various internal ports. The site I'm having
> trouble with is running on http://localhost:8082 internally, and on
> http://shared.furfly.net to everyone coming in through nginx.
>
> My problem is the value returned by [ns_conn location], which is
> http://shared.furfly.net:8082. This is partially correct; I told the
> site it's hostname is shared.furfly.net and it seems to be ok with that.
> But I can't get away with telling it that it's running on port 80, and
> [ns_conn location] seems to be returning whatever's in the config file.
> What I want, of course, is just http://shared.furfly.net.
>
> Is there some way to set this up so it returns the desired value, even
> though from AOLserver's point of view that's not exactly correct?
>
> thanks,
>
> janine
>
> ---
> Janine Ohmer (formerly Sisk)
> President/CEO of furfly, LLC
> 503-693-6407
>
>
> --
> AOLserver - http://www.aolserver.com/
>
> To Remove yourself from this list, simply send an email to <
> [email protected]> with the
> body of "SIGNOFF AOLSERVER" in the email message. You can leave the
> Subject: field of your email blank.
>
--
Best regards, Alexey Pechnikov.
http://pechnikov.tel/
--
AOLserver - http://www.aolserver.com/
To Remove yourself from this list, simply send an email to
<[email protected]> with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject:
field of your email blank.