$request_uri without args

agentzh agentzh at gmail.com
Wed Sep 14 15:39:01 UTC 2011

On Wed, Sep 14, 2011 at 10:30 PM, Richard Kearsley
<Richard.Kearsley at m247.com> wrote:
> I don't need args at backend - but I DO need the url still encoded

Use the following line of Lua to strip the query args part (if any)
from ngx.var.request (i.e., the nginx variable $request_uri):

    local uri = string.gsub(ngx.var.request_uri, "?.*", "")

and then you can feed the resulting uri variable into your subrequest
call instead of ngx.var.request_uri:

    local res = ngx.location.capture("/proxy" .. uri,
            { args =
                  { country = ngx.var.geoip_country_code, host = ngx.var.host }
            } )

Hope it works for you :)


More information about the nginx mailing list