You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Aaron Morris <aa...@mindspring.com> on 2003/07/06 21:20:43 UTC

Re: [users@httpd] port redirect (separate, but related issue)

I posted a question on the same issue a week or two ago, but received no 
response.

In the Apache documentation for "UseCanonicalName" it says:
"With UseCanonicalName off Apache will form self-referential URLs using 
the hostname and port supplied by the client if any are supplied..."

But from my experience and as is evident from this thread that Apache 
does NOT use port information supplied by the client to form 
self-referential URLs (it uses the port the connection was made on).

Here is an example from one of my environments where the webserver 
listens on a different port number (10000) than what you would connect 
to from the internet (80).  A frontend load-balancer does the port 
translation:
----
C:\>telnet 123.123.123.123 80
GET /home HTTP/1.0
Host: blah.gov:1234

HTTP/1.1 301 Moved Permanently
Date: Sun, 06 Jul 2003 18:50:11 GMT
Server: Apache
Location: http://blah.gov:10000/home/
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>301 Moved Permanently</TITLE>
</HEAD><BODY>
<H1>Moved Permanently</H1>
The document has moved <A HREF="http://blah.gov:10000/home/">here</A>.<P>
</BODY></HTML>
----

I have mitigated this issue by using mod_rewrite, but it does not change 
the fact that either the documentation is incorrect or Apache exhibits 
the incorrect behavior.

What needs to be done at this point?  Either the documentation needs to 
be corrected (or at least more clearly state the behavior) or notify the 
appropriate people about the "bug?" (through a bug report).  More or 
less, I'm trying to figure out if this is an Apache issue or a 
documentation issue.

Anyone want to take a shot at it?  :-)


Joshua Slive wrote:
> Whew, finally a few useful details ;-)
> 
> Anyway, the answer remains the same, but I can now be more specific about
> how to impliment it.  Place the following in httpd.conf (in place of any
> existing Listen/Port directives):
> 
> Listen 85
> Port 80
> ServerName www.blabla.de
> UseCanonicalName On
> 
> The Listen directive sets the actual port that apache will use to answer
> requests.  Port and ServerName tell apache how to identify itself when
> sending redirects.  UseCanonicalName tells apache to ignore the port and
> server name specified by the client in its request.
> 
> Joshua.


-- 
Aaron W Morris <aa...@mindspring.com> (decep)
PGP Key ID:  259978D1



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] port redirect (separate, but related issue)

Posted by Joshua Slive <jo...@slive.ca>.
On Sun, 6 Jul 2003, Aaron Morris wrote:
> In the Apache documentation for "UseCanonicalName" it says:
> "With UseCanonicalName off Apache will form self-referential URLs using
> the hostname and port supplied by the client if any are supplied..."
>
> But from my experience and as is evident from this thread that Apache
> does NOT use port information supplied by the client to form
> self-referential URLs (it uses the port the connection was made on).

The documentation could use some improvement.  Feel free to make
suggestions.

But I don't think the existing docs are strictly wrong.  The fact is,
the "port supplied by the client" could refer to one of two things.  The
client supplies a port by connecting to the appropriate port; the client
also supplies a port in the Host: header.  For hostname, it is simpler,
because there is no way to tell what "hostname" the client connected to,
so apache must use the one in the Host: header.

The docs should probably note that the port used is the connection port,
and not the port in the Host: header.

In general, well-configured hosts and simply use "UseCanonicalName On" and
make this problem go away.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org