https://bz.apache.org/bugzilla/show_bug.cgi?id=63504
Bug ID: 63504
Summary: Invalid port in redirects behing load balancer
Product: Apache httpd-2
Version: 2.5-HEAD
Hardware: PC
OS: All
Status: NEW
Severity: minor
Priority: P2
Component: Core
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
When I use a load balancer on the default port (http/80, https/443) that routes
request to an httpd instance listening on a non default port, httpd builds
redirects that include the load balancer's hostname but the port of the httpd
virtual host.
UseCanonicalName is turned off.
I've looked at the code in vhost.c that handles the Host header and the code in
core.c that builds the absolute URI used for the Location header in redirects
and my understanding is that when the absolute URI is computed the absence of a
port in the Host header of the request is treated as if there was no Host
header at all.
r->parsed_uri.port_str ? r->parsed_uri.port : ...
And parsed_uri.port_str is only set if there is a port in the Host header.
A workaround that I've come to use in multiple installations is to set the
ServerName with the default port inside the <VirtualHost> since this sets the
SERVER_PORT.
I've reproduced the issue with a very basic setup.
Listen 4080
<VirtualHost *:4080>
</VirtualHost>
And an empty test/ folder in the DocumentRoot.
When I call with an explicit port in the Host header everything works as
expected (I can supply any hostname it is echoed back in the Location header)
GET /test HTTP/1.1
Host: whatever:80
HTTP/1.1 301 Moved Permanently
Date: Fri, 14 Jun 2019 20:35:07 GMT
Server: Apache/2.5.1-dev (Unix)
Location: http://whatever/test/
When I call without a port in the Host header the Location header in the
response contains the server port but the hostname part of the Host header is
echoed back
GET /test HTTP/1.1
Host: whatever
HTTP/1.1 301 Moved Permanently
Date: Fri, 14 Jun 2019 20:35:09 GMT
Server: Apache/2.5.1-dev (Unix)
Location: http://whatever:4080/test/
I've reproduced the issue on httpd 2.2.8, 2.4.37 and a build from a fresh
checkout from 2.5-HEAD.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]