# Nginx hangs when you use try\_files, map, request\_uri and long url

**URL:** <https://www.ruby-forum.com/t/nginx-hangs-when-you-use-try-files-map-request-uri-and-long-url/220730>\
**Category:** NGINX\
**Created:** [June 18, 2012, 9:52pm UTC](https://www.ruby-forum.com/t/nginx-hangs-when-you-use-try-files-map-request-uri-and-long-url/220730 "2012-06-18T21:52:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [June 18, 2012, 9:52pm UTC](https://www.ruby-forum.com/t/nginx-hangs-when-you-use-try-files-map-request-uri-and-long-url/220730/1 "2012-06-18T21:52:26Z")

</div>

Hi,

For some reason, when I use long key with Map Module the whole nginx  
seems to hang.

Some background:  
I have two backends, say old\_app and new\_app. both have own named  
locations, @new\_app and old\_app. In order to redirect urls I tried to  
use:

map $request\_uri $map\_apps {  
default @new\_app;  
/asd @old\_app;  
}  
try\_files /not\_exist $map\_apps;

And it was working, then I added another key, 70 chars long, with  
commas, - and numbers, like “/foo-bar,123,asd-qwe-asdasdasd”

since the keyword have 70 chars I had to change default 64 value of  
map\_hash\_bucket\_size, I changed it to 128.

Now, if I access the ‘/foo-bar,123,asd-qwe-asdasdasd’ url, nginx just  
hangs, firefox return ‘connection reset’, wget seems to retry every 3s  
with message ‘no data’. I cant access any vhost, I cant even stop nginx,  
the workers ignore master, when I nginx -s stop, the workers are still  
alive, when I kill master with sigTERM, the workers are still alive,  
eventualy, after few minutes they starts working and support requests or  
just die.

The underlaying system is debian6, nginx version 1.1.19 (from  
squeeze-backports), 64bit.

even if I have only default entry in map, and then access the long url,  
the nginx hangs, but when I hash-out the map and try\_files lines, I can  
access the url and see 404 error.

fwiw I tried to use map since I have about 100 URLs that I want to  
proxy\_pass to old\_app, rest have to be handled by new\_app.

– Piotr.

---

<div class="post-metadata">

**Author:** ![hibernaculus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/6de8d8/32.png) [@hibernaculus](https://www.ruby-forum.com/u/hibernaculus)\
**Post date:** [June 18, 2012, 10:02pm UTC](https://www.ruby-forum.com/t/nginx-hangs-when-you-use-try-files-map-request-uri-and-long-url/220730/2 "2012-06-18T22:02:57Z")

</div>

Hello!

On Mon, Jun 18, 2012 at 09:51:31PM +0200, Piotr K. wrote:

> map $request\_uri $map\_apps {
> 
> even if I have only default entry in map, and then access the long  
> url, the nginx hangs, but when I hash-out the map and try\_files  
> lines, I can access the url and see 404 error.
> 
> fwiw I tried to use map since I have about 100 URLs that I want to  
> proxy\_pass to old\_app, rest have to be handled by new\_app.

The problem isn’t map, the problem is try\_files which is broken in  
1.1.19. Please upgrade to 1.2.0 at least, or apply the following  
patch:

[http://trac.nginx.org/nginx/changeset/4601/nginx](http://trac.nginx.org/nginx/changeset/4601/nginx)

Changes with nginx 1.2.0:

```
*) Bugfix: a segmentation fault might occur in a worker process if 

```

the  
“try\_files” directive was used; the bug had appeared in 1.1.19.

Maxim D.

---

<div class="post-metadata">

**Author:** ![hibernaculus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/6de8d8/32.png) [@hibernaculus](https://www.ruby-forum.com/u/hibernaculus)\
**Post date:** [June 19, 2012, 12:52pm UTC](https://www.ruby-forum.com/t/nginx-hangs-when-you-use-try-files-map-request-uri-and-long-url/220730/3 "2012-06-19T12:52:34Z")

</div>

Hello.

On 06/18/2012 10:02 PM, Maxim D. wrote:

> The problem isn’t map, the problem is try\_files which is broken in  
> 1.1.19. Please upgrade to 1.2.0 at least, or apply the following  
> patch:
> 
> [http://trac.nginx.org/nginx/changeset/4601/nginx](http://trac.nginx.org/nginx/changeset/4601/nginx)
> 
> Changes with nginx 1.2.0:
> 
> ```
> *) Bugfix: a segmentation fault might occur in a worker process if the
> "try_files" directive was used; the bug had appeared in 1.1.19.
> 
> ```

Thank you very much Maxim, the patch works. 😉

– Piotr.
