Держим у себя кастомный фронтэнд к твиттеру для наших пользователей.<br>Для того чтобы экономить траффик фетчим аватары с твиттера с помощью nginx.<br><br>Столкнулись с проблемой, некоторые сервера при запросе выдают ошибку.<br>
Написал небольшой скрипт для проверки и вот что получилось:<br><br>Если запрашивать &quot;GET 
<a href="http://s.twimg.com/a/1276654401/images/default_profile_5_normal.png">http://s.twimg.com/a/1276654401/images/default_profile_5_normal.png</a> 
HTTP/1.0&quot;, то тот же сервер выдает все правильно.<br>При запросе на <a href="http://s.twimg.com">s.twimg.com</a> &quot;GET /a/1276654401/images/default_profile_5_normal.png HTTP/1.0&quot;  выдает:<br><br>Server  CloudFront<br>
Via     1.0 <a href="http://8e9a4ae768e6927d3d01697a4e6e1232.cloudfront.net:11180">8e9a4ae768e6927d3d01697a4e6e1232.cloudfront.net:11180</a> (CloudFront)<br>Date    Thu, 17 Jun 2010 05:53:39 GMT<br>Connection      close<br>
X-Amz-Cf-Id     be57b17fcc523c0a3ecef717959faf719e589d78aa7b3f47d993f880bd79dc49de6122e53df4a7bd<br>Content-Length  1222<br>Content-Type    text/html<br>X-Cache Error from cloudfront<br>Expires Thu, 17 Jun 2010 05:53:39 GMT<br>
&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;<a href="http://www.w3.org/TR/html4/loose.dtd">http://www.w3.org/TR/html4/loose.dtd</a>&quot;&gt;<br>&lt;HTML&gt;&lt;HEAD&gt;&lt;META HTTP-EQUIV=&quot;Content-Type&quot; CONTENT=&quot;text/html; charset=iso-8859-1&quot;&gt;<br>
&lt;TITLE&gt;ERROR: The requested URL could not be retrieved&lt;/TITLE&gt;<br>&lt;STYLE type=&quot;text/css&quot;&gt;&lt;!--BODY{background-color:#ffffff;font-family:verdana,sans-serif}PRE{font-family:sans-serif}--&gt;&lt;/STYLE&gt;<br>
&lt;/HEAD&gt;&lt;BODY&gt;<br>&lt;H1&gt;ERROR&lt;/H1&gt;<br>&lt;H2&gt;The requested URL could not be retrieved&lt;/H2&gt;<br>&lt;HR noshade size=&quot;1px&quot;&gt;<br>&lt;P&gt;<br>While trying to retrieve the URL:<br>&lt;A HREF=&quot;a/1276654401/images/default_profile_5_normal.png&quot;&gt;a/1276654401/images/default_profile_5_normal.png&lt;/A&gt;<br>
&lt;P&gt;<br>The following error was encountered:<br>&lt;UL&gt;<br>&lt;LI&gt;<br>&lt;STRONG&gt;<br>Invalid URL<br>&lt;/STRONG&gt;<br>&lt;/UL&gt;<br><br>&lt;P&gt;<br>Some aspect of the requested URL is incorrect.  Possible problems:<br>
&lt;UL&gt;<br>&lt;LI&gt;Missing or incorrect access protocol (should be `http://&#39;&#39; or similar)<br>&lt;LI&gt;Missing hostname<br>&lt;LI&gt;Illegal double-escape in the URL-Path<br>&lt;LI&gt;Illegal character in hostname; underscores are not allowed<br>
&lt;/UL&gt;<br>&lt;P&gt;Your cache administrator is &lt;A HREF=&quot;mailto:<a href="mailto:webmaster">webmaster</a>&quot;&gt;webmaster&lt;/A&gt;. <br><br>&lt;BR clear=&quot;all&quot;&gt;<br>&lt;HR noshade size=&quot;1px&quot;&gt;<br>
&lt;ADDRESS&gt;<br>Generated Thu, 17 Jun 2010 05:53:39 GMT by cloudfront (CloudFront)<br>&lt;/ADDRESS&gt;<br>&lt;/BODY&gt;&lt;/HTML&gt;<br><br>Что странно, так себя ведут только некоторые сервера, на большинстве все ок.<br>
<br>Nginx посылает запросы, на которые выдается ошибка :(<br>Есть какой-нибудь способ изменить его поведение?<br><br>nginx version: nginx/0.7.65<br>Кусок конфига nginx:<br>------------------------<br>upstream twitter_upstream {<br>

        server <a href="http://s.twimg.com">s.twimg.com</a>                         ;<br>
        server <a href="http://a1.twimg.com">a1.twimg.com</a>   backup          ;<br>
}<br>------------------------<br>        location /stwimg/ {<br>                rewrite  ^/stwimg/(.*)$  /$1 break;<br>                root /var/www/twimg;<br>                open_file_cache_errors  off;<br>                log_not_found  off;<br>
                error_page 404 = /sfetch$uri;<br>        }<br>        location /sfetch/ {<br>                internal;<br><br>                rewrite  ^/sfetch/(.*)$  /$1 break;<br>                proxy_pass      <a href="http://twitter_upstream">http://twitter_upstream</a>;<br>
                open_file_cache_errors  off;<br><br>                proxy_set_header Host &quot;<a href="http://s.twimg.com">s.twimg.com</a>&quot;;<br><br>                proxy_buffering on;<br>                proxy_buffers 32 16k;<br>
<br>                proxy_store     on;<br>                proxy_temp_path /var/www/tmp;<br>                root /var/www/twimg;<br>        }<br>------------------------<br><br><br>