AJP13 misses to forward the remotePort.
authorrjung <rjung@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 21 Mar 2009 12:51:39 +0000 (12:51 +0000)
committerrjung <rjung@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 21 Mar 2009 12:51:39 +0000 (12:51 +0000)
Apache automatically sets the env variable
REMOTE_PORT to the remote port.

Allow the user to set "JkEnvVar REMOTE_PORT" and
let us accept the port in the forwarded attribute
as the remote port.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@756926 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/coyote/ajp/AjpAprProcessor.java
java/org/apache/coyote/ajp/AjpProcessor.java
java/org/apache/jk/common/HandlerRequest.java

index 14bcd9f..560b457 100644 (file)
@@ -716,6 +716,18 @@ public class AjpAprProcessor implements ActionHook {
                 requestHeaderMessage.getBytes(tmpMB);
                 String v = tmpMB.toString();
                 request.setAttribute(n, v);
+                /*
+                 * AJP13 misses to forward the remotePort.
+                 * Apache automatically sets REMOTE_PORT to the remote port.
+                 * Allow the user to set "JkEnvVar REMOTE_PORT" and
+                 * let us accept the forwarded port as the remote port.
+                 */
+                if(n.equals("REMOTE_PORT")) {
+                    try {
+                        request.setRemotePort(Integer.parseInt(v));
+                    } catch (NumberFormatException nfe) {
+                    }
+                }
                 break;
 
             case Constants.SC_A_CONTEXT :
index ba2b881..f4e20b3 100644 (file)
@@ -722,6 +722,18 @@ public class AjpProcessor implements ActionHook {
                 requestHeaderMessage.getBytes(tmpMB);
                 String v = tmpMB.toString();
                 request.setAttribute(n, v);
+                /*
+                 * AJP13 misses to forward the remotePort.
+                 * Apache automatically sets REMOTE_PORT to the remote port.
+                 * Allow the user to set "JkEnvVar REMOTE_PORT" and
+                 * let us accept the forwarded port as the remote port.
+                 */
+                if(n.equals("REMOTE_PORT")) {
+                    try {
+                        request.setRemotePort(Integer.parseInt(v));
+                    } catch (NumberFormatException nfe) {
+                    }
+                }
                 break;
 
             case Constants.SC_A_CONTEXT :
index 15a174d..0810e7d 100644 (file)
@@ -457,6 +457,18 @@ public class HandlerRequest extends JkHandler
                 req.setAttribute(n, v );
                 if(log.isTraceEnabled())
                     log.trace("jk Attribute set " + n + "=" + v);
+                /*
+                 * AJP13 misses to forward the remotePort.
+                 * Apache automatically sets REMOTE_PORT to the remote port.
+                 * Allow the user to set "JkEnvVar REMOTE_PORT" and
+                 * let us accept the forwarded port as the remote port.
+                 */
+                if(n.equals("REMOTE_PORT")) {
+                    try {
+                        req.setRemotePort(Integer.parseInt(v));
+                    } catch (NumberFormatException nfe) {
+                    }
+                }
             }