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

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.

After upgrading to Nginx 1.2.0 (configure arguments:
–pid-path=/var/run/nginx.pid --conf-path=/etc/nginx/core.conf
–error-log-path=/var/log/nginx/nginx.log --user=wwwrun
–group=nogroup --with-ipv6 --without-poll_module
–without-select_module --with-file-aio --with-http_ssl_module
–with-http_addition_module --with-http_xslt_module
–with-http_image_filter_module --with-http_sub_module
–with-http_dav_module --with-http_flv_module --with-http_mp4_module
–with-http_gzip_static_module --with-http_random_index_module
–with-http_degradation_module --with-http_stub_status_module
–http-log-path=/var/log/nginx --with-pcre --with-pcre-jit
–prefix=/usr --with-cc-opt=’-O3 -march=native -Wl,–hash-style=gnu
-Wl,-O1 -flto -Wl,-z,relro’ --with-ld-opt=’-L/usr/lib64 -L/lib64’
–without-http_ssi_module --without-http_uwsgi_module
–without-http_scgi_module --without-http_upstream_ip_hash_module
–without-http_split_clients_module --without-http_empty_gif_module)
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 .)

Kind regards
Dilian

The “?” is getting urlencoded to %3F. I think nginx url-encodes
during internal re-directs

–Ashish

On Tue, May 1, 2012 at 7:45 AM, Dilyan Palauzov

Hello!

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

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.

[…]

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 D.

Hello,

The “?” is obviously urlencoded to %3f in 1.2.0, but it wasn’t in 1.0.15
.

Greetings
Dilyan Palauzov

----- Message from Ashish S [email protected] ---------
Date: Tue, 1 May 2012 08:40:13 -0700
From: Ashish S [email protected]
Reply-To: [email protected]
Subject: Re: question mark transformed to %3f on internal redirects
with Nginx 1.2.0
To: [email protected]

proxy_set_header X-Real-IP $remote_addr;
–with-http_image_filter_module --with-http_sub_module
error message from thttpd:
“cgi-bin/wa%3fINDEX not found” problem .)
nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx

----- End message from Ashish S [email protected] -----