tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 12052] New: - mod_jk sets wrong port (uses socket port, not user specified port)
Date Mon, 26 Aug 2002 19:39:32 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12052>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12052

mod_jk sets wrong port (uses socket port, not user specified port)

           Summary: mod_jk sets wrong port (uses socket port, not user
                    specified port)
           Product: Tomcat 4
           Version: 4.0.4 Final
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Connector:JK/AJP (deprecated)
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: ide@nlm.nih.gov


request.getServerPort() currently returns the socket port instead
of the port specified by the user.  (These can be different if a 
load balancer or firewall is redirecting ports.)


See line 465 of mod_jk.c (Revision 1.26)

My C code is a bit rusty, but I replaced that line:

s->server_port     = htons( r->connection->local_addr.sin_port );

with:

/* Pick default values for port of 80/443.  */
/* Then use the values from HOST header if they are available. */

    {
    const char *host_header;
    int port = 80;	/* good default if no HOST header */
    int is_ssl = 0;
    char parsed_server[256];
    int parsed=0;
    host_header = ap_table_get(r->headers_in, "Host");
    if(conf->ssl_enable) {
            char *ssl_temp;
            ssl_temp = (char *)ap_table_get(r->subprocess_env,
conf->https_indicator);
            if(ssl_temp && !strcasecmp(ssl_temp, "on")) {
                is_ssl = 1;
                port = 443;   /* good default if no HOST hdr and ssl */
            }
    }

    if (host_header)    /* get the port from Host: if possible */
        {
        int tmp_port;
        const char *s = strchr(host_header, ':');
        if (s != NULL) {
            ++s;        /* past the colon */
            if (sscanf (s,"%d", &tmp_port) == 1) port = tmp_port;
        }
        }

/** set the good port value */
    s->server_port = port;
    }

By the way, I believe the Apache <VirtualHost> logic has the same problem.

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message