Details
-
Type:
New Feature
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Component/s: HTTP
-
Labels:None
-
Environment:Jetty behind a reverse proxy (especially Apache HTTPD with mod_proxy_http for example)
-
Testcase included:yes
-
Patch Submitted:Yes
-
Number of attachments :
Description
When Jetty is behind a reverse proxy it is not possible to retrieve the following properties of the original request :
- getServerName()
- getServerPort()
- getRemoteAddr()
This is typically the case when you use a ProxyPass directive with Apache HTTPD and mod_proxy_http.
Tomcat use proxyName and proxyPort for retrieving original host and port:
http://tomcat.apache.org/tomcat-5.5-doc/proxy-howto.html
So i have created a Handler for wrapping the request and providing these original properties when possible.
This handler can be used in two different ways:
- like Tomcat if at least the serverName property is set
- mod_proxy_http if the serverName property is not set and then headers from reverse proxy are used
By default mod_proxy_http headers are used:
http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#x-headers
Sébastien,
this has been something that we have been meaning to support out-of-the-box - but have not got around to it,as it has been easy to do on a case by case basis.
So I would like to include support for this. However, may I suggest a better way to implement it than a handler, because wrapping requests is expensive and can cause other issues.
If you put the handling in AbstractConnector.customize(Endpoint,Request), then that is called for every request
and you are able to directly call request.setServerName(String) and request.setServerPort.
It would be good to protect this handling with a boolean, as looking for headers is also a little expensive and so it would be best not to check for the headers unless the connector was configured with the boolean true (setCheckingProxyHeaders(true) or connector.setServerName to have a defined server.
So it would be great if you could morph you patch to that.... otherwise I'll try to get to this later in the month.