Картинки из амазона

Алферов Василий vasilii.alferov на gmail.com
Чт Июн 17 11:00:17 MSD 2010


Держим у себя кастомный фронтэнд к твиттеру для наших пользователей.
Для того чтобы экономить траффик фетчим аватары с твиттера с помощью nginx.

Столкнулись с проблемой, некоторые сервера при запросе выдают ошибку.
Написал небольшой скрипт для проверки и вот что получилось:

Если запрашивать "GET
http://s.twimg.com/a/1276654401/images/default_profile_5_normal.pngHTTP/1.0",
то тот же сервер выдает все правильно.
При запросе на s.twimg.com "GET
/a/1276654401/images/default_profile_5_normal.png HTTP/1.0"  выдает:

Server  CloudFront
Via     1.0 8e9a4ae768e6927d3d01697a4e6e1232.cloudfront.net:11180(CloudFront)
Date    Thu, 17 Jun 2010 05:53:39 GMT
Connection      close
X-Amz-Cf-Id
be57b17fcc523c0a3ecef717959faf719e589d78aa7b3f47d993f880bd79dc49de6122e53df4a7bd
Content-Length  1222
Content-Type    text/html
X-Cache Error from cloudfront
Expires Thu, 17 Jun 2010 05:53:39 GMT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html;
charset=iso-8859-1">
<TITLE>ERROR: The requested URL could not be retrieved</TITLE>
<STYLE
type="text/css"><!--BODY{background-color:#ffffff;font-family:verdana,sans-serif}PRE{font-family:sans-serif}--></STYLE>
</HEAD><BODY>
<H1>ERROR</H1>
<H2>The requested URL could not be retrieved</H2>
<HR noshade size="1px">
<P>
While trying to retrieve the URL:
<A
HREF="a/1276654401/images/default_profile_5_normal.png">a/1276654401/images/default_profile_5_normal.png</A>
<P>
The following error was encountered:
<UL>
<LI>
<STRONG>
Invalid URL
</STRONG>
</UL>

<P>
Some aspect of the requested URL is incorrect.  Possible problems:
<UL>
<LI>Missing or incorrect access protocol (should be `http://'' or similar)
<LI>Missing hostname
<LI>Illegal double-escape in the URL-Path
<LI>Illegal character in hostname; underscores are not allowed
</UL>
<P>Your cache administrator is <A HREF="mailto:webmaster">webmaster</A>.

<BR clear="all">
<HR noshade size="1px">
<ADDRESS>
Generated Thu, 17 Jun 2010 05:53:39 GMT by cloudfront (CloudFront)
</ADDRESS>
</BODY></HTML>

Что странно, так себя ведут только некоторые сервера, на большинстве все ок.

Nginx посылает запросы, на которые выдается ошибка :(
Есть какой-нибудь способ изменить его поведение?

nginx version: nginx/0.7.65
Кусок конфига nginx:
------------------------
upstream twitter_upstream {
        server s.twimg.com                         ;
        server a1.twimg.com   backup          ;
}
------------------------
        location /stwimg/ {
                rewrite  ^/stwimg/(.*)$  /$1 break;
                root /var/www/twimg;
                open_file_cache_errors  off;
                log_not_found  off;
                error_page 404 = /sfetch$uri;
        }
        location /sfetch/ {
                internal;

                rewrite  ^/sfetch/(.*)$  /$1 break;
                proxy_pass      http://twitter_upstream;
                open_file_cache_errors  off;

                proxy_set_header Host "s.twimg.com";

                proxy_buffering on;
                proxy_buffers 32 16k;

                proxy_store     on;
                proxy_temp_path /var/www/tmp;
                root /var/www/twimg;
        }
------------------------
----------- следущая часть -----------
Вложение в формате HTML было извлечено&hellip;
URL: <http://nginx.org/pipermail/nginx-ru/attachments/20100617/ee010aaf/attachment-0001.html>


Подробная информация о списке рассылки nginx-ru