On 13 November 2012 10:01, Igor Sysoev <span dir="ltr"><<a href="mailto:igor@sysoev.ru" target="_blank">igor@sysoev.ru</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div style="word-wrap:break-word"><div><div><div class="h5"><div>On Nov 13, 2012, at 12:41 , Nilshar wrote:</div><br></div></div><blockquote type="cite"><div><div class="h5">On 13 November 2012 09:38, Igor Sysoev <span dir="ltr"><<a href="mailto:igor@sysoev.ru" target="_blank">igor@sysoev.ru</a>></span> wrote:<br>
<div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div style="word-wrap:break-word"><div><div><div><div>On Nov 13, 2012, at 12:32 , Nilshar wrote:</div><br><blockquote type="cite"><span style="font-family:arial,sans-serif;font-size:13px">Hello list,</span><div style="font-family:arial,sans-serif;font-size:13px">

<br></div><div style="font-family:arial,sans-serif;font-size:13px">I got an issue with a filename containing "strange" characters.</div>
<div style="font-family:arial,sans-serif;font-size:13px">It seems that nginx is not able to url_decode correctly, and then get the right file.</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">


Yes, the filename is ugly : "Capture d’écran 2010-09-25 à 08.30.07.png"</div><div style="font-family:arial,sans-serif;font-size:13px">but apache is able to read it, and nginx is not :</div><div style="font-family:arial,sans-serif;font-size:13px">


<br></div><div style="font-family:arial,sans-serif;font-size:13px">nginx strace :</div><div style="font-family:arial,sans-serif;font-size:13px">open("/<path>/images/Capture%20d%E2%80%99%C3%A9cran%202010-09-25%20%C3%A0%2008.30.07.png", O_RDONLY|O_NONBLOCK) = -1 ENOENT (No such file or directory)</div>


<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">apache strace :</div><div style="font-family:arial,sans-serif;font-size:13px">open("/<path>/images/Capture d\342\200\231\303\251cran 2010-09-25 \303\240 08.30.07.png", O_RDONLY|O_CLOEXEC) = 100</div>


<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">So it seems that nginx is using the url_encoded version of the filename, while apache do it's own thing on it.</div>


<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">On both apache and nginx, the access log says : "GET /images/Capture%20d%E2%80%99%C3%A9cran%202010-09-25%20%C3%A0%2008.30.07.png"</div>


<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">both server have the same locales settings, and I tried different charset configuration into nginx, but no luck..</div>


<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Any idea how I can fix that without changing the filename (sadly, it's not possible :/) ?</div>


</blockquote></div><div><br></div></div></div>The most probably there is a rewrite in configuration which changes URI to $request_uri.<div>nginx escapes URI if no one interferes.<br><div><div><br></div></div></div></div>
</blockquote></div><br></div></div></div><div class="im"><div class="gmail_extra">Yes indeed, there is a rewrite !<br>got a tip on how to fix that ?</div></div></blockquote></div><div><br></div>The general rule is to not use rewrites at all: they make configuration to a mess.<div class="im">
<br><div><br><div>
<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:-webkit-auto;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Georgia;word-spacing:0px"><span style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:-webkit-auto;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Georgia;word-spacing:0px"><div style="word-wrap:break-word">
<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Georgia;word-spacing:0px"><br>
--<br>Igor Sysoev<br></span></div><div style="word-wrap:break-word"><span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Georgia;word-spacing:0px"><a href="http://nginx.com/support.html" target="_blank">http://nginx.com/support.html</a></span></div>
</span></span>
</div>
</div></div></div></blockquote></div><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><font color="#500050">Hum... well ok, if I read it right, it is recommanded to use try_files instead right ?</font></div>
<div class="gmail_extra"><font color="#500050">Problem is that it seems that try_files is not allowed inside a "if"...</font></div><div class="gmail_extra"><font color="#500050"><br></font></div><div class="gmail_extra">
<font color="#500050">Well.. maybe someone will be able to point me a better conf, here what I'm trying to do :</font></div><div class="gmail_extra"><font color="#500050"><br></font></div><div class="gmail_extra"><font color="#500050"><div class="gmail_extra">
        location ~ ^/(media|files|list|album|images)/ {</div><div class="gmail_extra">                root /;</div><div class="gmail_extra">                if ($host ~* "^(.)(.)(.*)\.<a href="http://example.com">example.com</a>$") {</div>
<div class="gmail_extra">                        set $dir1 $1;</div><div class="gmail_extra">                        set $dir2 $2;</div><div class="gmail_extra">                        set $dir3 $3;</div><div class="gmail_extra">
                        rewrite ^ /<path>/<a href="http://www.example.com/$dir1/$dir2/$dir1$dir2$dir3$request_uri">www.example.com/$dir1/$dir2/$dir1$dir2$dir3$request_uri</a>? break;</div><div class="gmail_extra">                }</div>
<div class="gmail_extra">        }</div><div><br></div><div>So I should be able to remove the if so try_files might be happy, but I do not know how to set the 3 dir w/o the if statement..</div><div>I tried several things, so far no luck.</div>
<div><br></div><div>Nilshar</div></font></div>