durusmail: quixote-users: Re: Medusa bug or user misunderstanding?
Medusa bug or user misunderstanding?
2004-01-21
2004-01-21
2004-01-21
Re: Medusa bug or user misunderstanding?
2004-01-21
2004-01-21
2004-01-21
Medusa bug or user misunderstanding?
2004-01-21
2004-01-22
Re: Medusa bug or user misunderstanding? [patch files]
2004-01-22
Jason E. Sibre (3 parts)
Re: Medusa bug or user misunderstanding? [patchfiles]
2004-02-04
2004-02-05
Medusa bug or user misunderstanding?
2004-01-22
2004-01-21
Re: Medusa bug or user misunderstanding?
Graham Fawcett
2004-01-21
xA.M. Kuchling wrote:

> On Wed, Jan 21, 2004 at 02:35:39PM -0500, Graham Fawcett wrote:
>
>>Andrew's suggestion looks like a winner: it gives a nice failover in
>>case 'Host' is not included in the request header.
>
>
> One corner case: I'm not sure what happens if a port is specified.  Does
> Host: contain "servername:8080"?  Is it OK to include the port in the
> SERVER_NAME variable?

D'oh. You're right about the Host header: it includes the port. If the
port is not specified, the default port for the service is implied.

After a re-read of the CGI spec, it turns out that SERVER_NAME is "not
request-specific and [is] set for all requests". So, according to
CGI/1.1, SERVER_NAME should not be equivalent to the Host header.

I've concluded that I don't like the CGI spec any more, and put my trust
  in de-facto standards. Namely: what does Apache/FCGI do?

I set up a quick proxy at machine1:8080 which passes requests to an
Apache server at machine2:80. Names have been changed to protect the
innocent. Not a real HTTP proxy, BTW, just used Sam Rushing's
proxy_server class from his Medusa writings.

Whipped up a quick PHP page (ugh, I know, but I don't have Python on
that machine):

HTTP_HOST: ". $_SERVER["HTTP_HOST"];
echo "

SERVER_NAME: ". $_SERVER["SERVER_NAME"]; echo "

SERVER_PORT: ". $_SERVER["SERVER_PORT"]; ?> The results were interesting. Hitting my proxy at http://machine1:8080/graham/test.php machine2 returned these results: HTTP_HOST: machine1:8080 SERVER_NAME: machine1 SERVER_PORT: 80 I assume that the PHP interpreter did not fiddle with the results. The SERVER_PORT is the port that Apache is listening on, not the port from my Host header. Interesting, but to be fair I wasn't using a real HTTP proxy; maybe it would have responded differently... but maybe not. In conclusion, Apache/FGCI uses the hostname in HTTP_HOST to set the SERVER_NAME variable, and thus is in flagrant violation of the "non-request-specific" directive in the CGI spec. ;-) Futhermore, it does not include the port in SERVER_NAME. QED. I'd suggest that http_request.py be changed to use HTTP_HOST instead of SERVER_NAME for any redirects, if HTTP_HOST is present. -- Graham

reply