FastCGI applications needs the Host header, which is missing in HTTP/2.
This commit is contained in:
parent
30affa57c7
commit
aef2f42b5b
|
@ -946,7 +946,7 @@ public class HttpClient extends ContainerLifeCycle
|
|||
return port > 0 ? port : HttpScheme.HTTPS.is(scheme) ? 443 : 80;
|
||||
}
|
||||
|
||||
protected boolean isDefaultPort(String scheme, int port)
|
||||
public boolean isDefaultPort(String scheme, int port)
|
||||
{
|
||||
return HttpScheme.HTTPS.is(scheme) ? port == 443 : port == 80;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.eclipse.jetty.client.api.Request;
|
|||
import org.eclipse.jetty.fcgi.FCGI;
|
||||
import org.eclipse.jetty.fcgi.client.http.HttpClientTransportOverFCGI;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpScheme;
|
||||
import org.eclipse.jetty.proxy.AsyncProxyServlet;
|
||||
import org.eclipse.jetty.proxy.ProxyServlet;
|
||||
|
@ -127,6 +128,16 @@ public class FastCGIProxyServlet extends AsyncProxyServlet.Transparent
|
|||
proxyRequest.attribute(REQUEST_URI_ATTRIBUTE, originalURI);
|
||||
}
|
||||
|
||||
// If the Host header is missing, add it.
|
||||
if (!proxyRequest.getHeaders().containsKey(HttpHeader.HOST.asString()))
|
||||
{
|
||||
String host = request.getServerName();
|
||||
int port = request.getServerPort();
|
||||
if (!getHttpClient().isDefaultPort(request.getScheme(), port))
|
||||
host += ":" + port;
|
||||
proxyRequest.header(HttpHeader.HOST, host);
|
||||
}
|
||||
|
||||
super.customizeProxyRequest(proxyRequest, request);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue