users@jersey.java.net

[Jersey] Mixing HTTP proxies and UriInfo.getBaseUriBuilder()

From: cowwoc <cowwoc_at_bbs.darktech.org>
Date: Wed, 31 Jul 2013 04:15:47 -0400

Hi,

     I've got an internal server at http://localhost:1006/. I configured
Apache Httpd to proxy it as http://host.com/foo/ as follows:

RewriteEngine On
# Redirect the client if the URL is missing a slash
RewriteRule ^/foo$ foo/ [R,L]

ProxyPass /foo/ http://localhost:1006/
ProxyPassReverse /foo/ http://host.com/
ProxyPassReverseCookiePath / /foo/
<Location /foo>
     Require all granted
</Location>

     When the server returns a Location header pointing to
http://localhost:1006/ it gets rewritten as http://host.com/foo/. So far
so good.

     The problem is when I invoke UriInfo.getBaseUriBuilder() I get
http://host.com/ (external Host, but internal Path). This gets returned
in a JSON response body and since httpd only examines headers it goes
unchanged.

     What is the appropriate way to fix this proxing problem? I read
that configuring httpd to intercept entity bodies is error-prone. Is
there any way for me to look up the public Path? Where is
UriInfo.getBaseUriBuilder() getting its Path information from?

Thanks,
Gili