Note that there are some explanatory texts on larger screens.

plurals
  1. POretrieving the client source port on a HTTPD -> Tomcat setting
    primarykey
    data
    text
    <p>I have an httpd server configured to handle HTTPS connections and forward the connections to a Tomcat (via http or ajp) where the requests are processed. One of the requirements I have in the Tomcat server is to log the remote port number of each request. If I hit the Tomcat directly, retrieving the remote port number is straight forward and we are currently doing it using the <code>getRemotePort()</code> function (HttpServletRequest). </p> <p>However, since I'm doing a reverse proxy (forwarding HTTPS requests via HTTP/AJP) a new connection will be created and I'll always get the remote port (and remote IP for that matter) for the connection from my httpd server to tomcat (except when I use AJP. In this case the remote server IP info comes correctly).</p> <p>I've tried different configurations on httpd, like: </p> <pre><code>ProxyPreserveHost On ProxyPass / ajp://localhost:8009/ </code></pre> <p>or</p> <pre><code>ProxyPreserveHost On ProxyPass / http://localhost:8081/ </code></pre> <p>I also played a little bit with RewriteRules, but couldn't make things work.</p> <p>Reading httpd documentation, mod_proxy offers request header information for things like <code>X-Forwarded-Host</code>, <code>X-Forwarded-For</code>, etc. But there is no info about source port.</p> <p>I've <a href="http://mail-archives.apache.org/mod_mbox/httpd-bugs/200304.mbox/%3C20030401191204.13726.qmail@nagoya.betaversion.org%3E">even found a bug</a>, where apparently a <code>X-Forwarded-Port</code> attribute was added to the proxy request header, but that code doesn't seem to have made to the main line/branch.</p> <p>So, in summary, how can I retrieve the source port of the client (not the reverse proxy) when HTTPD is forwarding requests to Tomcat?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload