msgbartop
Blog di Bernardino (Dino) Ciuffetti
msgbarbottom

05 Mar 13 How to get the client source port with apache as reverse proxy

Retrieving the client IP address from an application deployed in tomcat, jboss, bea weblogic o something else sitting behind a reverse proxy is a simple matter of getting the Proxy HTTP headers setted by apache, for example”X-Forwarded-Host”, “X-Forwarded-For”, etc.

Sometimes, in enterprise environments, you could be asked to find the solution that make the application able to get the client source port too. In some cases, the police could ask the client’s provider to show the real identity of the contract person using the HTTP service, and in natted environments it’s impossible for the provider to do this without the source port.

Well, if your reverse proxy is apache, the solution is simple. Just add those lines to your httpd.conf:

RewriteEngine on
RewriteRule .* – [E=REMOTE_PORT:%{REMOTE_PORT},NE]
RequestHeader set X-Forwarded-SourcePort %{REMOTE_PORT}e

This way apache will set the HTTP request Header called “X-Forwarded-SourcePort“. The application can now get the TCP client source port.

Lascia un commento

*