You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by "Chet Hosey (JIRA)" <ji...@apache.org> on 2013/02/13 17:32:13 UTC

[jira] [Commented] (TOMEE-757) UriInfo given by embedded CXF-RS uses wrong port on AJP connections

    [ https://issues.apache.org/jira/browse/TOMEE-757?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13577686#comment-13577686 ] 

Chet Hosey commented on TOMEE-757:
----------------------------------

Sorry, my report must not have been clear. I'll restate the issue since I believe TomEE 1.5.2 will address this issue.

Consider a load balancer running on www.example.com:80 which forwards requests to internal hosts app-server-1.example.com:8080 and app-server-2.example.com:8080.

The public identity of the service is http://www.example.com on port 80. In TomEE 1.5.1, UriInfo uses the connector information as the basis for URIs. On a default installation, it would return "localhost:8080". But the internal hostnames and ports are implementation details that should not be exposed in generated URIs. The right behavior would be to use "www.example.com:80" to generate the URI.

So UriInfo should use the HTTP "Host" header information. Or it should get the data from HttpServletRequest.getServerName()/getServerPort(), which can be configured by an administrator.
                
> UriInfo given by embedded CXF-RS uses wrong port on AJP connections
> -------------------------------------------------------------------
>
>                 Key: TOMEE-757
>                 URL: https://issues.apache.org/jira/browse/TOMEE-757
>             Project: TomEE
>          Issue Type: Improvement
>    Affects Versions: 1.5.1
>         Environment: TomEE JAX-RS 1.5.1 on Java 1.7.0_11 64-bit, proxied through Apache httpd 2.2.23 and mod_jk 1.2.37 using AJP, running on Debian stable
>            Reporter: Chet Hosey
>            Priority: Minor
>
> The UriInfo object provided by @Context injection under JAX-RS provides URIs based on the Tomcat server.xml configuration. The host name can be changed from "localhost" by changing the virtual host configuration. However there's no clear way to change the port number returned by the UriInfo methods, other than to change the actual HTTP connector port in server.xml to the desired value.
> This has the unfortunate result that each TomEE instance would have to listen on its own IP address to get the port numbers to match, if the calculated URIs need to be consistent across instances. And each TomEE instance would also need elevated privileges to bind to port 80, if that is the desired URI port.
> In my mind the least surprising behavior would be to match the values available via a @Context HttpServletRequest object, such as getServerName() and getServerPort(), at least for AJP connections.
> Below is sample output from UriInfo, HttpHeaders, and HttpServletRequest objects passed to a JAX-RS method:
>    uriInfo.getAbsolutePath(): http://localhost:8080/sample-app-1.0-SNAPSHOT/
>    uriInfo.getBaseUri(): http://localhost:8080/sample-app-1.0-SNAPSHOT
>    uriInfo.getRequestUri(): http://localhost:8080/sample-app-1.0-SNAPSHOT/
>    httpServletRequest.getLocalAddr(): 1.2.3.4
>    httpServletRequest.getLocalName(): www.example.com
>    httpServletRequest.getLocalPort(): 80
>    httpServletRequest.getServerName(): www.example.com
>    httpServletRequest.getServerPort(): 80
>    host:
>        www.example.com

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira