Re: server port number in requests
André Warnier wrote:[color=blue]
> John ORourke wrote:[color=green]
>> Hi folks,
>> I can't seem to find a way to retrieve the inbound port number during
>> I have a server listening on multiple ports, and need to know which
>> one the request came in on. Here's the setup:
>> apache config:
>> Listen 127.0.0.1:81
>> Listen 127.0.0.1:82
>> NameVirtualHost *:*
>> <VirtualHost *:*>
> I believe you could resolve this as follows (although it is really a
> "brute force" method) :
> Instead of one <VirtualHost *:*>, you could define 2 sections, entirely
> copy of eachother except for :
> <VirtualHost *:81>
> PerlSetVar ConnType "HTTP"
> <VirtualHost *:82>
> PerlSetVar ConnType "HTTPS"
> and then in your script/handler get the ConnType config value to tell
> the difference.
Apart from he brute force method above, I believe there must be numerous
other ways to achieve best what you really need.
For instance, I would have a look at the Apache SetEnvIf configuration
directive, which may be used to set an environment variable later
retrieved by your script/module.
I would also imagine that a HTTPS request already includes some specific
HTTP headers which a HTTP request does not have, and you could test for
that (either in the script/module or with SetEnvIf).
Which method really works best in your case, and which is the most
efficient, is left as an exercise to the reader.