Commit 267728b9 authored by Sander Striker's avatar Sander Striker
Browse files

Make the combination of mod_proxy_ajp and mod_rewrite work correctly.

* modules/proxy/proxy_ajp.c

  (ap_proxy_ajp_request): Update call to ajp_send_header().


* modules/proxy/ajp.h

  (ajp_send_header): Add a uri parameter.


* modules/proxy/ajp_header.c

  (ajp_marshal_into_msgb): Add a uri parameter and use the
   passed in uri instead of r->uri.

  (ajp_send_header): Add a uri parameter.  Update call to
   ajp_marshal_into_msgb().


* modules/mappers/mod_rewrite.c

  (is_absolute_uri): Add handling of 'ajp' and 'balancer' schemes.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@124584 13f79535-47bb-0310-9956-ffa450edef68
parent c8841c99
Loading
Loading
Loading
Loading
+13 −0
Changes for modules/mappers/mod_rewrite.c: 13 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -558,6 +558,19 @@ static unsigned is_absolute_uri(char *uri)
    }

    switch (*uri++) {
    case 'a':
    case 'A':
        if (!strncasecmp(uri, "jp://", 5)) {        /* ajp://    */
          return 6;
        }

    case 'b':
    case 'B':
        if (!strncasecmp(uri, "alancer://", 10)) {   /* balancer:// */
          return 11;
        }
        break;

    case 'f':
    case 'F':
        if (!strncasecmp(uri, "tp://", 5)) {        /* ftp://    */
+3 −1
Changes for modules/proxy/ajp.h: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -384,9 +384,11 @@ apr_status_t ajp_ilink_receive(apr_socket_t *sock, ajp_msg_t *msg);
 * Build the ajp header message and send it
 * @param sock      backend socket
 * @param r         current request
 * @uri uri         requested uri
 * @return          APR_SUCCESS or error
 */
apr_status_t ajp_send_header(apr_socket_t *sock, request_rec  *r);
apr_status_t ajp_send_header(apr_socket_t *sock, request_rec *r,
                             apr_uri_t *uri);

/**
 * Read the ajp message and return the type of the message.
+8 −16
Changes for modules/proxy/ajp_header.c: 8 added lines, 16 removed lines.
Original line number Diff line number Diff line
@@ -204,13 +204,13 @@ AJPV13_REQUEST/AJPV14_REQUEST=
 */

static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
                                 request_rec *r)
                                          request_rec *r,
                                          apr_uri_t *uri)
{
    int method;
    apr_uint32_t i, num_headers = 0;
    apr_byte_t is_ssl;
    char *remote_host;
    char *uri;
    const char *session_route, *envvar;
    const apr_array_header_t *arr = apr_table_elts(r->subprocess_env);
    const apr_table_entry_t *elts = (const apr_table_entry_t *)arr->elts;
@@ -235,21 +235,12 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,

    remote_host = (char *)ap_get_remote_host(r->connection, r->per_dir_config, REMOTE_HOST, NULL);

    uri = apr_pstrdup(r->pool, r->uri);
    if (uri != NULL) {
        char *query_str = strchr(uri, '?');
        if (query_str != NULL) {
            *query_str = 0;
        }
    }
    

    ajp_msg_reset(msg);

    if (ajp_msg_append_uint8(msg, CMD_AJP13_FORWARD_REQUEST)     ||
        ajp_msg_append_uint8(msg, method)                        ||
        ajp_msg_append_string(msg, r->protocol)                  ||
        ajp_msg_append_string(msg, uri)                          ||
        ajp_msg_append_string(msg, uri->path)                    ||
        ajp_msg_append_string(msg, r->connection->remote_ip)     ||
        ajp_msg_append_string(msg, remote_host)                  ||
        ajp_msg_append_string(msg, ap_get_server_name(r))        ||
@@ -327,9 +318,9 @@ static apr_status_t ajp_marshal_into_msgb(ajp_msg_t *msg,
        }
    }
    /* XXXX  ebcdic (args converted?) */
    if (r->args) {
    if (uri->query) {
        if (ajp_msg_append_uint8(msg, SC_A_QUERY_STRING) ||
            ajp_msg_append_string(msg, r->args)) {
            ajp_msg_append_string(msg, uri->query)) {
            ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
                   "Error ajp_marshal_into_msgb - "
                   "Error appending the query string");
@@ -563,7 +554,8 @@ static apr_status_t ajp_unmarshal_response(ajp_msg_t *msg,
 * Build the ajp header message and send it
 */
apr_status_t ajp_send_header(apr_socket_t *sock,
                                  request_rec  *r)
                             request_rec *r,
                             apr_uri_t *uri)
{
    ajp_msg_t *msg;
    apr_status_t rc;
@@ -575,7 +567,7 @@ apr_status_t ajp_send_header(apr_socket_t *sock,
        return rc;
    }

    rc = ajp_marshal_into_msgb(msg, r);    
    rc = ajp_marshal_into_msgb(msg, r, uri);    
    if (rc != APR_SUCCESS) {
        ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
               "ajp_send_header: ajp_marshal_into_msgb failed");
+2 −2
Changes for modules/proxy/proxy_ajp.c: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -125,7 +125,7 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r,
     */

    /* send request headers */
    status = ajp_send_header(conn->sock, r);
    status = ajp_send_header(conn->sock, r, uri);
    if (status != APR_SUCCESS) {
        conn->close++;
        ap_log_error(APLOG_MARK, APLOG_ERR, status, r->server,
@@ -341,7 +341,7 @@ static int ap_proxy_ajp_request(apr_pool_t *p, request_rec *r,
}

/*
 * This handles http:// URLs, and other URLs using a remote proxy over http
 * This handles ajp:// URLs, and other URLs using a remote proxy over http
 * If proxyhost is NULL, then contact the server directly, otherwise
 * go via the proxy.
 * Note that if a proxy is used, then URLs other than http: can be accessed,