question mark transformed to %3f on internal redirects with Nginx 1.2.0

Maxim Dounin mdounin at mdounin.ru
Wed May 2 16:21:18 UTC 2012


Hello!

On Tue, May 01, 2012 at 04:45:52PM +0200, Dilyan Palauzov wrote:

> Hello,
> 
> I have a rule
> server {
> ...
>   index index.php /cgi-bin/wa?INDEX;
> }
> 
> /cgi-bin/wa is forwarded to a thhpd server:
> 
> location /cgi-bin {
>   proxy_pass http://lists.aegee.org:8080;
>   proxy_set_header X-Real-IP $remote_addr;
>   proxy_pass_request_headers on;
> }
> 
> and it works with Nginx 1.1.15.

[...]

> and invoking the site, that redirects internally to
> /cgi-bin/wa?INDEX, I get an error message from thttpd:
> 
> 404 Not Found
> The requested URL '/cgi-bin/wa%3fINDEX' was not found on this server.
> 
> But, if I request directly /cgi-bin/wa?INDEX in the browser,
> everything works perfect.
> 
> I think there is something in Nginx 1.2.0, that rewrites the
> question mark in %3f for internal redirects, that was not done in
> 1.0.15 and I would like to have the old behaviour back (or hints,
> how to solve the "cgi-bin/wa%3fINDEX not found" problem .)

In 1.0.15 this resulted in original request uri passed to 
upstream server, and probably that's why it worked for you.  The 
'?' was never handled specially in index directive arguments (i.e. 
it was always subject to escaping if passed to upstream server).

To actually request "/cgi-bin/wa?INDEX" (in both 1.2.0 and 1.0.15) 
you may try something like this:

    index index.php /index;

    location = /index {
        proxy_pass http://lists.aegee.org:8080/cgi-bin/wa?INDEX;
        ...
    }

If you want previous behaviour, try something like this:

    location /cgi-bin/ {
        proxy_pass http://lists.aegee.org:8080$request_uri;
        ...
    }

(note that this will also result in dynamic resolution of 
"lists.aegee.org", so you either have to define upstream{} with 
the name in question, or configure a resolver)

Maxim Dounin



More information about the nginx mailing list