You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs@httpd.apache.org by Tony Finch <do...@dotat.at> on 2001/02/20 03:26:49 UTC

Re: Incorrect behaviour in ap_get_server_port()?

Lars Oppermann <la...@germany.sun.com> wrote:
>
>Now, whenever a self-referencing, absolute URL is to be constructed, it
>has to point to said application responsible for request distribution,
>and not to the particular Apache server that generated the response
>containing this URL. To achive this, we set the 'Host:' header in the
>request sent from the distributing application to the Apache server
>accordingly. This does indeed work for hostnames, but not for
>Portnumbers (UseCanonicalName is turned off in Apache).

Gosh, this is becoming a *very* frequently asked question. I'm not
sure where we can improve the documentation to make it clearer, though.

Use the "Listen" directive to configure the port that Apache listens
on, and use the "Port" directive to configure the port that Apache
uses to refer to itself.

e.g. with
	Listen 8000
	Port 80
Apache accepts requests on port 8000 but when generating redirects or
other self-referential URLs it uses port 80. This is designed to work
in exactly your situation.

Tony.
-- 
f.a.n.finch    fanf@covalent.net    dot@dotat.at
VIKING NORTH UTSIRE SOUTH UTSIRE: WEST OR NORTHWEST 5 INCREASING 6 OR 7. RAIN
THEN SHOWERS. MODERATE OR GOOD.

Re: Incorrect behaviour in ap_get_server_port()?

Posted by Lars Oppermann <la...@germany.sun.com>.
Tony Finch wrote:
> 
> Lars Oppermann <la...@germany.sun.com> wrote:
> >
> >Now, whenever a self-referencing, absolute URL is to be constructed, it
> >has to point to said application responsible for request distribution,
> >and not to the particular Apache server that generated the response
> >containing this URL. To achive this, we set the 'Host:' header in the
> >request sent from the distributing application to the Apache server
> >accordingly. This does indeed work for hostnames, but not for
> >Portnumbers (UseCanonicalName is turned off in Apache).
> 
> Gosh, this is becoming a *very* frequently asked question. I'm not
> sure where we can improve the documentation to make it clearer, though.
> 
> Use the "Listen" directive to configure the port that Apache listens
> on, and use the "Port" directive to configure the port that Apache
> uses to refer to itself.
> 

This is true, as long as the value for the 'Port' directive can be
determined before apache is started and is the same for all entrypoints
that relay requests to the apache server.

However I am of the opinion that the content of the Host header supplied
by the client should be used when UseCanonicalNames is turned off. I
don't think that the current behaviour of using the portnumber through
which the connection was made whenever a host header is present
(hostname in the request_rec is set) or else fall back to the value of
the Port directive is realy the right way to handle this.

What do you think?

Greetings,
Lars
-- 
----------------------------------------------------------------------
Lars Oppermann                                        Sun Microsystems
Software Engineer                                      Staroffice GmbH  
Phone: +49 40 23646 959                                  Sachsenfeld 4
Fax:   +49 40 23646 550                                D-20097 Hamburg
lars.oppermann@germany.sun.com           http://www.sun.com/staroffice
----------------------------------------------------------------------