-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Path-based routes fail when the Host header includes a port #8471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It occurs to me that a simpler reproduction case would be to not bother with the Steps To Reproduce
Current Result# oc create -f subpath.yml
deploymentconfig "nginx-subpath" created
service "nginx-subpath" created
Error from server: imagestreams "origin-path-nginx" already exists
# oc expose svc nginx-subpath --hostname=pathtest.apps.redacted.com --path=/subdir/
route "nginx-subpath" exposed
# curl http://pathtest.apps.redacted.com/subdir/
This is the child server.
# curl -H 'Host: pathtest.apps.redacted.com:80' http://pathtest.apps.redacted.com/subdir/
<html>
<body>
<h1>503 Service Unavailable</h1>
No server available to handle the request.
</body>
</html> The last step results in an HTTP 503 error. Expected ResultThe last step should instead output |
Okay, I did some experimentation and modifying the template to add another line with the correct port does indeed work. I'll submit a pull request shortly. |
I have submitted #8490, which provides a solution to this issue. |
This is done to support path-based routing for clients that include the port number in the Host header. While unusual, doing so isn't against the HTTP spec, and some clients force it. Fixes openshift#8471.
This is done to support path-based routing for clients that include the port number in the Host header. While unusual, doing so isn't against the HTTP spec, and some clients force it. Fixes openshift#8471.
This is done to support path-based routing for clients that include the port number in the Host header. While unusual, doing so isn't against the HTTP spec, and some clients force it. Fixes openshift#8471.
This is done to support path-based routing for clients that include the port number in the Host header. While unusual, doing so isn't against the HTTP spec, and some clients force it. Fixes openshift#8471.
Path-based routes are not correctly dispatched if the client includes the port in the
Host
header. While including the port number in requests to HTTP(S) endpoints on standard port numbers is unusual, it is not against the spec, and some clients force it.Version
Steps To Reproduce
root.yml
andsubpath.yml
from this gist to your system.oc create -f root.yml
. This creates a service using a simple nginx container that serves this content.oc expose svc nginx-root --hostname=pathtest.$ROUTERDOMAIN
oc create -f subpath.yml
. This creates a service using the same nginx container that serves this content.oc expose svc nginx-subpath --hostname=pathtest.$ROUTERDOMAIN --path=/subdir/
curl
the root:curl http://pathtest.$ROUTERDOMAIN/
curl
the subdir:curl http://pathtest.$ROUTERDOMAIN/subdir/
curl
the subdir with the port in the Host header:curl -H 'Host: pathtest.$ROUTERDOMAIN:80' http://pathtest.$ROUTERDOMAIN/subdir/
Current Result
The last step outputs
This is still the master server.
Expected Result
The last step should instead output
This is the child server.
This is a result of using
map_beg
in HAProxy againstbase
, which is defined as "the concatenation of the first Host header and the path part of the request". In other words, in the last request,base
is equal topathtest.apps.redacted.com:80/subdir/
, which does not matchpathtest.apps.redacted.com/subdir/
.The text was updated successfully, but these errors were encountered: