6 Replies Latest reply on Jan 28, 2010 2:59 AM by Jean-Frederic Clere

    Query string truncation

    Edwin Babadaglian Newbie

      Greetings.

      I've been experimenting with mod_cluster 1.1.0.Beta1 along with Apache HTTPD 2.2.13 and Tomcat 6.0.20 and I'm investigating an apparent query-string truncation occurring between HTTPD and Tomcat. For example, I'll submit an application request like so ...

      http://devhost/params/?name=edwin&state=NY

      ... and the resulting page suggests that no query parameters were passed. I dug a bit further and expanded some of the tracing code in mod_proxy/proxy_util.c/ap_proxy_determine_connection and inspected the contents of a few variables and found the following after resubmitting the request:

      missing -> path='/headersParams/'
      missing -> query=''
      found -> request_rec->uri='/headersParams/'
      found -> request_rec->unparsed_uri='/headersParams/?name=edwin&state=NY'
      found -> request_rec->parsed_uri.query='name=edwin&state=NY'
      found -> request_rec->args='name=edwin&state=NY'

      I also employed 'wireshark' to inspect the AJP request from HTTPD to Tomcat and didn't see the query-string present, presumably in 'AJP13_FORWARD_REQUEST.req_uri' field.

      Does the query-string appear to be getting lost somewhere through 'mod_cluster' processing or is this more of an HTTPD-related issue?


      Many thanks for any help and for the good work going into this project.
      -Edwin

        • 1. Re: Query string truncation
          Vernon Crandall Newbie

          Have you found a solution to this problem? I am working on the same issue. Everything works except the query_string is dropped. I have tried adding rewrite rules without success as it truncates the query_string value out after the rewrite.It seems to be some kind of a limitation with the proxy balancer.

           

          This will be a problem with our REST web services and the GET.

           

              RewriteEngine On
              RewriteLog "D:/bin/httpd-2.2/logs/rewrite_log"
              RewriteLogLevel 9

               #tried all of these:

              #RewriteRule "^(/.*)$" "proxy:balancer://av.biz.local$1?%{QUERY_STRING}" [QSA,L]
              RewriteRule "^(/.*)$" "proxy:balancer://av.biz.local$1?%{QUERY_STRING}" [L]
              #RewriteRule "^(/.*)$" "proxy:balancer://av.biz.local$1" [QSA,L]
              ProxyPass / balancer://av.biz.local/ stickySession=JSESSIONID|jsessionid

           

          Here is the rewrite log with a simple example where the args added in then split back out.

           

          127.0.0.1 - - [15/Jan/2010:13:12:35 --0700] [127.0.0.1/sid#10cf568][rid#15f4838/initial] (2) init rewrite engine with requested uri /ws/services/CapService
          127.0.0.1 - - [15/Jan/2010:13:12:35 --0700] [127.0.0.1/sid#10cf568][rid#15f4838/initial] (3) applying pattern '^(/.*)$' to uri '/ws/services/CapService'
          127.0.0.1 - - [15/Jan/2010:13:12:35 --0700] [127.0.0.1/sid#10cf568][rid#15f4838/initial] (2) rewrite '/ws/services/CapService' -> 'proxy:balancer://av.biz.local/ws/services/CapService?wsdl'
          127.0.0.1 - - [15/Jan/2010:13:12:35 --0700] [127.0.0.1/sid#10cf568][rid#15f4838/initial] (3) split uri=proxy:balancer://av.biz.local/ws/services/CapService?wsdl -> uri=proxy:balancer://av.biz.local/ws/services/CapService, args=wsdl
          127.0.0.1 - - [15/Jan/2010:13:12:35 --0700] [127.0.0.1/sid#10cf568][rid#15f4838/initial] (1) go-ahead with proxy request proxy:balancer://av.biz.local/ws/services/CapService [OK]

          • 2. Re: Query string truncation
            Edwin Babadaglian Newbie

            Here's my latest attempt, and please do share your observations:

             

             

            --- mod_cluster/native/mod_proxy/proxy_util.c   (revision 135)
            +++ mod_cluster/native/mod_proxy/proxy_util.c   (working copy)
            @@ -2063,8 +2063,8 @@
                  */
                 /* are we connecting directly, or via a proxy? */
                 if (!proxyname) {
            -        *url = apr_pstrcat(p, uri->path, uri->query ? "?" : "",
            -                           uri->query ? uri->query : "",
            +        *url = apr_pstrcat(p, uri->path, r->args ? "?" : "",
            +                           r->args ? r->args : "",
                                        uri->fragment ? "#" : "",
                                        uri->fragment ? uri->fragment : "", NULL);
                 }

             

             

            Regards,

            Edwin

            • 3. Re: Query string truncation
              Vernon Crandall Newbie

              I see two possible solutions at this time: Modify mod_proxy or mangle the URL with the querystring and unmangle it on the back end.

              I will reply when I have something tested.

               

              The think that concerns me about changing mod_proxy is that the documentation clearly states that the query_string data will not be passed via ProxyPass but I haven't found a reason why this is the case on the internet. Is there a special reason for this limitation? I prefer HTTP POST commands for regular web pages but many REST web services rely on the query_string parameters for GET.

              • 4. Re: Query string truncation
                Jean-Frederic Clere Master
                Changing ./modules/proxy/proxy_util.c is not a good idea because it is just a patched version of the ASF httpd one.
                • 5. Re: Query string truncation
                  Vernon Crandall Newbie

                  I have found a configuration that will work with mod_cluster 1.0.3.GA but it will not work with 1.1.0 Beta1.

                   

                  I added "nocanon" to ProxyPass and disabled all of the RewriteRules I was experimenting with.

                   

                   

                  ProxyPass / balancer://av.biz.local/ stickySession=JSESSIONID|jsessionid nocanon

                   

                  I also tried a lot of variations with Proxy, ProxySet, and RewriteRules but this always truncated the query_string from the request. nocanon was only available using ProxyPass.

                   

                  Exerpt from mod_proxy documentation:

                  ProxyPass [path] !|url [key=value key=value ...]] [nocanon] [interpolate]

                   

                  Normally, mod_proxy will canonicalise ProxyPassed URLs. But this may be incompatible with some backends, particularly those that make use of PATH_INFO. The optional nocanon keyword suppresses this, and passes the URL path "raw" to the backend. Note that may affect the security of your backend, as it removes the normal limited protection against URL-based attacks provided by the proxy.

                   

                  Thanks for all the suggestions.

                  • 6. Re: Query string truncation
                    Jean-Frederic Clere Master
                    I confirm that it is a bug in 1.1.x (MODCLUSTER-118).