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