-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Jetty 12 generates wrong Host header #10306
Comments
@joakime, I recall you and I working on the HostPort code.... which I think we have got wrong here: If the URI (which includes the authority received either via the Host header or the HTTP2 authority header) does not have a port, then the server port should be the logical port for the scheme (80 or 443), unless it has been forced to a specific port by the server authority. |
Hi, So this looks like a duplicate of #10304 ! |
It also happens with HTTP/1.1. |
I've done a tentative fix in #10311. It initially has not broken any tests that I tried (doing a full build now), so that is a) good in that nothing depending on previous behaviour ; b) bad we are not testing this very well! |
Should be fixed with #10311 |
Jetty version: 12.0.0
Jetty environment: ee10 (embedded Jetty server configured to use HTTP/2)
Java version: openjdk version "20.0.1" 2023-04-18
OpenJDK Runtime Environment (Red_Hat-20.0.1.0.9-2.rolling.fc38) (build 20.0.1+9)
OpenJDK 64-Bit Server VM (Red_Hat-20.0.1.0.9-2.rolling.fc38) (build 20.0.1+9, mixed mode, sharing)
OS: Fedora 38, Ubuntu 23.04
Jetty returns the wrong host header when a request is forwarded from a different port. In my case the client sends a request to the default port 443 which is then forwarded to port 8443 which is the port Jetty listens on. The host header then incorrectly contains the port number 8443.
Server receives this (pardon the brackets):
request.getRequestURL().toString():
URL=[https://demo.jambo.software/demo.jambo.software/s;x=13y762q065p53vl8nbmb4uf720]
request.getHeader(...):
HEADER[sec-fetch-mode]=[cors]
HEADER[content-length]=[26]
HEADER[sec-fetch-site]=[same-origin]
HEADER[accept-language]=[en-US,en;q=0.9]
HEADER[cookie]=[13y762q065p53vl8nbmb4uf720=A25F3449-F86C-4545-805E-45F947465397]
HEADER[origin]=[https://demo.jambo.software/]
HEADER[Host]=[demo.jambo.software:8443]
HEADER[accept]=[/]
HEADER[sec-gpc]=[1]
HEADER[sec-ch-ua]=["Not/A)Brand";v="99", "Brave";v="115", "Chromium";v="115"]
HEADER[sec-ch-ua-mobile]=[?0]
HEADER[sec-ch-ua-platform]=["Linux"]
HEADER[content-type]=[application/vnd.piglet]
HEADER[accept-encoding]=[gzip, deflate, br]
HEADER[user-agent]=[Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36]
HEADER[sec-fetch-dest]=[empty]
While the netword tab of the browser gives this for the request:
Request URL:https://demo.jambo.software/demo.jambo.software/s;x=13y762q065p53vl8nbmb4uf720
Request Method:POST
Status Code:200
Remote Address:136.144.238.65:443
Referrer Policy:no-referrer
:authority:demo.jambo.software
:method:POST
:path:/demo.jambo.software/s;x=13y762q065p53vl8nbmb4uf720
:scheme:https
Accept:/
Accept-Encoding:gzip, deflate, br
Accept-Language:en-US,en;q=0.9
Content-Length:26
Content-Type:application/vnd.piglet
Cookie:13y762q065p53vl8nbmb4uf720=A25F3449-F86C-4545-805E-45F947465397
Origin:https://demo.jambo.software/
Sec-Ch-Ua:"Not/A)Brand";v="99", "Brave";v="115", "Chromium";v="115"
Sec-Ch-Ua-Mobile:?0
Sec-Ch-Ua-Platform:"Linux"
Sec-Fetch-Dest:empty
Sec-Fetch-Mode:cors
Sec-Fetch-Site:same-origin
Sec-Gpc:1
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
The text was updated successfully, but these errors were encountered: