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

**URL:** <https://www.ruby-forum.com/t/question-mark-transformed-to-3f-on-internal-redirects-with-nginx-1-2-0/219383>\
**Category:** NGINX\
**Created:** [May 1, 2012, 4:46pm UTC](https://www.ruby-forum.com/t/question-mark-transformed-to-3f-on-internal-redirects-with-nginx-1-2-0/219383 "2012-05-01T16:46:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [May 1, 2012, 4:46pm UTC](https://www.ruby-forum.com/t/question-mark-transformed-to-3f-on-internal-redirects-with-nginx-1-2-0/219383/1 "2012-05-01T16:46:29Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![Dilyan\_Palauzov](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b3f665/32.png) [@Dilyan\_Palauzov](https://www.ruby-forum.com/u/Dilyan_Palauzov)\
**Post date:** [May 1, 2012, 5:40pm UTC](https://www.ruby-forum.com/t/question-mark-transformed-to-3f-on-internal-redirects-with-nginx-1-2-0/219383/2 "2012-05-01T17:40:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Dilyan\_Palauzov](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b3f665/32.png) [@Dilyan\_Palauzov](https://www.ruby-forum.com/u/Dilyan_Palauzov)\
**Post date:** [May 2, 2012, 6:22pm UTC](https://www.ruby-forum.com/t/question-mark-transformed-to-3f-on-internal-redirects-with-nginx-1-2-0/219383/3 "2012-05-02T18:22:04Z")

</div>

Hello!

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

> location /cgi-bin {  
> proxy\_pass [http://lists.aegee.org:8080](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](http://lists.aegee.org)”, so you either have to define upstream{} with  
the name in question, or configure a resolver)

Maxim D.

---

<div class="post-metadata">

**Author:** ![Dilyan\_Palauzov](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b3f665/32.png) [@Dilyan\_Palauzov](https://www.ruby-forum.com/u/Dilyan_Palauzov)\
**Post date:** [May 1, 2012, 9:22pm UTC](https://www.ruby-forum.com/t/question-mark-transformed-to-3f-on-internal-redirects-with-nginx-1-2-0/219383/4 "2012-05-01T21:22:46Z")

</div>

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 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) ---------  
Date: Tue, 1 May 2012 08:40:13 -0700  
From: Ashish S [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Reply-To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: question mark transformed to %3f on internal redirects  
with Nginx 1.2.0  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> > 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  
> > [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> > [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)

----- End message from Ashish S [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) -----
