Hi John

> The underlying reason for this is that I have a reverse proxy in
> front
> of it, which proxies HTTP and HTTPS requests. The back-end needs to
> create self-referencing URLs but cannot tell if it's HTTP or HTTPS, so I
> decided to direct HTTP to port 81 and HTTPS to port 82. I'd prefer to
> do it by adding a request header so if someone knows a way to do that
> please let me know!

You can do this with $request->get_server_port

However, what I'm doing is running a single server on my backend
machines, and then on my proxy (I'm using Pound), I have this config:

Address x.x.x.x
Port 80
HeadRemove "X-Forwarded-For"
HeadRemove "X-HTTPS"
RewriteLocation 0

Address x.x.x.x
Port 443
Cert "/path/to/cert.pem"
HeadRemove "X-Forwarded-For"
AddHeader "X-HTTPS: 1"
RewriteLocation 0