Hi, On Thu, Jul 30, 2020 at 11:47 AM Travis Spencer <[email protected]> wrote: > > We are trying to add H2 support to our server that embeds Jetty. This > works perfectly except in the case where we proxy to downstream > services. For a couple routes, we forward to an HTTP (not HTTPS) > server and a server that doesn't support H2. In these cases, the proxy > request fails since non-SSL with H2 isn't supported by the one origin > server and the other only accepts 1.1. > > So, my question is, how in our AsyncProxyServlet subclass should we > specify that the proxy requests should use HTTP 1.1 and not H2? ATM, > the proxied request seems to always use whatever version the client > used when communicating with the proxy servlet.
I am not sure I understand. You have a server that is both a server (i.e. it answers requests directly) and a proxy (i.e. it uses AsyncProxyServlet to forward to other servers that only support HTTP/1.1). Because you are using Jetty 9.4.x you don't have the dynamic HttpClient transport available in 10.0.x, but that is not an issue since the other servers only support HTTP/1.1. AsyncProxyServlet will create an instance of HttpClient with (by default) the HTTP/1.1 transport. So every proxied request will be sent as HTTP/1.1. Therefore it is already the case that all proxied requests use HTTP/1.1. > When access the downstream HTTP 1.1 server, the client and proxy > request looks like this: > > MyGoodTransparentProxyServlet:70 474713221 rewriting: > https://localhost:5555/mygood-api -> > https://remote.example.com:443/some-other-good-api Uh? You said the other server was not using HTTPS? > HttpRequest[GET /some-other-good-api HTTP/2.0]@8c22593 > accept-language: en-US,en;q=0.5 > content-type: application/json > cache-control: no-cache > pragma: no-cache > accept: application/json, text/plain, */* > X-Forwarded-For: 0:0:0:0:0:0:0:1 > X-Forwarded-Proto: https > X-Forwarded-Host: localhost:5555 > X-Forwarded-Server: 0:0:0:0:0:0:0:1 > Via: 2.0 Y762xIGev8Am > > Note the Via header as well. I could not call addProxyHeaders in my > subclass anymore because that calls addViaHeader, which seems to have > a few bugs in it: > > * HTTP is used when RFC 7230 says it shouldn't be except when the > protocol isn't HTTP (there's no MUST on this, but, in section 5.7.1, > it says "For brevity, the protocol-name is omitted when the received > protocol is HTTP.") Don't understand? The protocol *is* HTTP. > * "null" is used if ViaHost isn't configured. Instead, a pseudonym > should be used Where is "null"? > * The protocol version is hard coded to be 1.1 when, in my case at > least, it should be 2.0. Uh? But you said you want to use HTTP/1.1. Really confused, sorry. -- Simone Bordet ---- http://cometd.org http://webtide.com Developer advice, training, services and support from the Jetty & CometD experts. _______________________________________________ jetty-users mailing list [email protected] To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users
