You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by wolfgang <wo...@gmail.com> on 2009/01/18 20:36:14 UTC

How to get a port number.

Hi there,

I can not get a port number if my apache module is set in the main
server config and listen port is set to 10080.
( "the main server config" means other than virtual host configs. )

When my apache module is set in the main server config as follows and
a client requests "http://www.example.com:10080".

In httpd.conf,
...
Listen 10080
<Location "/">
   SetHandler mymodule
</Location>
....

Then, in mymodule I get the following results.

request_rec->server->is_virtual is 0.
ap_get_server_port(request_rec)" is 80.          <----- 80 !? why not 10080 ??
request_rec->server->port is 0.                      <----- ZERO !? hm...
request_rec->server->addrs->host_port is 0.   <----- ZERO... Sure, my
module is not in a virtual host.

But if I set the module in a virtual host config as follows and a
client requests "http://www.example.com:10080"

In httpd.conf,
...
Listen 10080
NameVirtualHost *:10080
<VirtualHost *:10080>
    ServerName www.example.com
    DocumentRoot "htdocs"
    ...
  <Location "/">
    SetHandler mymodule
  </Location>
</VirtualHost>

Then, in mymodule I get the following results.

request_rec->server->is_virtual is 1.
ap_get_server_port(request_rec)" is 80.
request_rec->server->port is 0.
request_rec->server->addrs->host_port is 10080.  <--- GOTCHA !

How can I get the port number when my apache module is set in the main
server config ??

The version of my apache is 2.2.11 with mod_ssl but EAPI is not enabled.


Regards,

wolfgang

Re: How to get a port number.

Posted by Eric Covener <co...@gmail.com>.
On Sun, Jan 18, 2009 at 2:36 PM, wolfgang <wo...@gmail.com> wrote:
> Hi there,
>
> I can not get a port number if my apache module is set in the main
> server config and listen port is set to 10080.
> ( "the main server config" means other than virtual host configs. )
>
> When my apache module is set in the main server config as follows and
> a client requests "http://www.example.com:10080".
>
> In httpd.conf,
> ...
> Listen 10080
> <Location "/">
>   SetHandler mymodule
> </Location>
> ....
>
> Then, in mymodule I get the following results.
>
> request_rec->server->is_virtual is 0.
> ap_get_server_port(request_rec)" is 80.          <----- 80 !? why not 10080 ??
> request_rec->server->port is 0.                      <----- ZERO !? hm...
> request_rec->server->addrs->host_port is 0.   <----- ZERO... Sure, my
> module is not in a virtual host.
>

Maybe http://httpd.apache.org/docs/2.2/mod/core.html#usecanonicalphysicalport ?

(or ServerName if it's the only Listen)

-- 
Eric Covener
covener@gmail.com

Re: How to get a port number.

Posted by Ray Morris <su...@bettercgi.com>.
   Look at the host name.  It will at times 
include :portnumber - perhaps any time it's 
not the defaulot 80.
--
Ray B. Morris
support@bettercgi.com



On 01/18/2009 01:36:14 PM, wolfgang wrote:
> Hi there,
> 
> I can not get a port number if my apache module is set in the main
> server config and listen port is set to 10080.
> ( "the main server config" means other than virtual host configs. )
> 
> When my apache module is set in the main server config as follows and
> a client requests "http://www.example.com:10080".
> 
> In httpd.conf,
> ...
> Listen 10080
> <Location "/">
>    SetHandler mymodule
> </Location>
> ....
> 
> Then, in mymodule I get the following results.
> 
> request_rec->server->is_virtual is 0.
> ap_get_server_port(request_rec)" is 80.          <----- 80 !? why not
> 10080 ??
> request_rec->server->port is 0.                      <----- ZERO !?
> hm...
> request_rec->server->addrs->host_port is 0.   <----- ZERO... Sure, my
> module is not in a virtual host.
> 
> But if I set the module in a virtual host config as follows and a
> client requests "http://www.example.com:10080"
> 
> In httpd.conf,
> ...
> Listen 10080
> NameVirtualHost *:10080
> <VirtualHost *:10080>
>     ServerName www.example.com
>     DocumentRoot "htdocs"
>     ...
>   <Location "/">
>     SetHandler mymodule
>   </Location>
> </VirtualHost>
> 
> Then, in mymodule I get the following results.
> 
> request_rec->server->is_virtual is 1.
> ap_get_server_port(request_rec)" is 80.
> request_rec->server->port is 0.
> request_rec->server->addrs->host_port is 10080.  <--- GOTCHA !
> 
> How can I get the port number when my apache module is set in the 
> main
> server config ??
> 
> The version of my apache is 2.2.11 with mod_ssl but EAPI is not
> enabled.
> 
> 
> Regards,
> 
> wolfgang
> 
>