lighttpd forum lighty > SERVER_PORT implementation

Posted by Tim Bellen
on 06.05.2008 14:32
I noticed the following error

When I do a http request to lighttpd with php via a firewall that DNAT's
to another destination port from 80 to 81 than when I look at the ENV
variable SERVER_PORT it says it is port 81 while the same setup with
apache gives me port 80 which is the original destination port of the
request before the DNAT happened.

According to me SERVER_PORT should be the DPORT to which the request was
sent and not the actual port the server listens on.
http://hoohoo.ncsa.uiuc.edu/cgi/env.html

IS this a bug or can it be fixed with some config I do not know about ?

Thanks,

Tim Bellen
Posted by Olaf van der Spek
on 06.05.2008 16:30
Tim Bellen wrote:
> According to me SERVER_PORT should be the DPORT to which the request was
> sent and not the actual port the server listens on.

Both are equal. You're asking for the port of the original request.
Where does Apache get the 80 from though? It might be the Host header.

> http://hoohoo.ncsa.uiuc.edu/cgi/env.html

I doubt they meant the original port number.

> IS this a bug or can it be fixed with some config I do not know about ?
Posted by Tim Bellen (Guest)
on 10.05.2008 11:13
Olaf van der Spek wrote:
> Tim Bellen wrote:
>> According to me SERVER_PORT should be the DPORT to which the request was
>> sent and not the actual port the server listens on.
> 
> Both are equal. You're asking for the port of the original request.
> Where does Apache get the 80 from though? It might be the Host header.
> 
No they are not. At least not when a DPORT nat is involved. then apache 
gives me the DPORT of the request BEFORE it was natted so he gets it 
from some http header in the request.

>> http://hoohoo.ncsa.uiuc.edu/cgi/env.html
> 
> I doubt they meant the original port number.
> 
>> IS this a bug or can it be fixed with some config I do not know about ?
Posted by Olaf van der Spek
on 10.05.2008 18:58
Tim Bellen wrote:
> Olaf van der Spek wrote:
>> Tim Bellen wrote:
>>> According to me SERVER_PORT should be the DPORT to which the request was
>>> sent and not the actual port the server listens on.
>> 
>> Both are equal. You're asking for the port of the original request.
>> Where does Apache get the 80 from though? It might be the Host header.
>> 
> No they are not. At least not when a DPORT nat is involved. then apache 
> gives me the DPORT of the request BEFORE it was natted so he gets it 
> from some http header in the request.

I'm not saying Apache's behaviour doesn't differ.
I'm just saying it's unlikely that's what the specs prescribe.