Всем доброго времени суток, камрады!<br><br>Есть тривиальная, в общем-то, задача: перед скачиванием файлов из определенной папки показываться пользователю некую страницу, чтобы тот так или иначе подтвердил, что он имеет право его скачивать. Скрипт отдает X-Accel-Redirect заголовок после проверки, после чего nginx возвращает 404, хотя файл есть.<br>
<br>Вот как собран nginx (раньше был 0.6.что-то-там из портов, обновил в попытке решить проблему):<br><br>nginx version: nginx/0.8.53<br>built by gcc 4.3.2 (Debian 4.3.2-1.1)<br>TLS SNI support enabled<br>configure arguments: --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/body --http-proxy-temp-path=/var/lib/nginx/proxy --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --with-debug --with-http_stub_status_module --with-http_flv_module --with-http_ssl_module --with-http_dav_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module<br>
<br>Вот конфиг:<br>server {<br> listen 80;<br> server_name <a href="http://lmml.name/" target="_blank">lmml.name</a>;<br><br> access_log /var/log/nginx/lmml.name.access.log;<br> error_log /var/log/nginx/lmml.name.error.log debug;<br>
<br> location / {<br> root /var/www/<a href="http://lmml.name/httpdocs" target="_blank">lmml.name/httpdocs</a>;<br> index index.php index.html index.htm;<br> }<br><br> location /data {<br> internal;<br>
error_page 404 /download.php?path=$uri;<br> root /var/www/<a href="http://lmml.name/httpdocs" target="_blank">lmml.name/httpdocs</a>;<br> }<br> <br> location ~ \.php$ {<br> fastcgi_pass unix:/var/run/php-fpm/default.socket;<br>
fastcgi_index index.php;<br> fastcgi_param SCRIPT_FILENAME /var/www/<a href="http://lmml.name/httpdocs$fastcgi_script_name" target="_blank">lmml.name/httpdocs$fastcgi_script_name</a>;<br> include fastcgi_params;<br>
}<br><br> location ~ /\.ht {<br> deny all;<br> }<br>}<br><br>Вот debug log:<br><br><span lang="RU">
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http upstream connect: 0</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http upstream send request</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 chain writer buf fl:0 s:1192</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 chain writer in: 09FACA60</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 writev: 1192</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 chain writer out: 00000000</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 event timer add: 14: 60000:3477507303</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http finalize request: -4, "/download.php?path=/data/test.test" a:1, c:3</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http request count:3 blk:0</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http finalize request: -4, "/download.php?path=/data/test.test" a:1, c:2</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http request count:2 blk:0</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 post event B7B7A0A4</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 delete posted event B7B7A0A4</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http upstream request: "/download.php?path=/data/test.test"</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http upstream dummy handler</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 post event B7BAF0A4</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 post event B7B7A0A4</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 delete posted event B7B7A0A4</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http upstream request: "/download.php?path=/data/test.test"</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http upstream dummy handler</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 delete posted event B7BAF0A4</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http upstream request: "/download.php?path=/data/test.test"</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http upstream process header</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 malloc: 09FACCD8:4096</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 recv: fd:14 184 of 4096</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http fastcgi record byte: 01</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http fastcgi record byte: 06</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http fastcgi record byte: 00</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http fastcgi record byte: 01</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http fastcgi record byte: 00</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http fastcgi record byte: 9D</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http fastcgi record byte: 03</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http fastcgi record byte: 00</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http fastcgi record length: 157</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http fastcgi parser: 0</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http fastcgi header: "X-Powered-By: PHP/5.2.6-1+lenny4.fpm.4"</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http fastcgi parser: 0</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http fastcgi header: "X-Accel-Redirect: /data/test.test"</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http fastcgi parser: 0</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http fastcgi header: "Content-type: "</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http fastcgi parser: 0</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http fastcgi header: "Content-Disposition: attachment; filename="test.test""</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http fastcgi parser: 1</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http fastcgi header done</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 finalize http upstream request: -5</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 finalize http fastcgi request</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 free rr peer 1 0</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 close http upstream connection: 14</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 event timer del: 14: 3477507303</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 internal redirect: "/data/test.test?"</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 rewrite phase: 0</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 test location: "/"</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 test location: "data"</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 test location: ~ "\.php$"</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 test location: ~ "/\.ht"</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 using configuration "/data"</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http cl:-1 max:1048576</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 rewrite phase: 2</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 post rewrite phase: 3</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 generic phase: 4</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 generic phase: 5</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 access phase: 6</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 access phase: 7</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 post access phase: 8</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 content phase: 9</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 content phase: 10</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 content phase: 11</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 content phase: 12</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http filename: "/var/www/<a href="http://lmml.name/httpdocs/data/test.test">lmml.name/httpdocs/data/test.test</a>"</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 add cleanup: 09FACC2C</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http static fd: 14</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http set discard body</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 posix_memalign: 09FADCE0:4096 @16</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 HTTP/1.1 404 Not Found</p>
<p>Server: nginx/0.8.53</p>
<p>Date: Thu, 21 Oct 2010 14:51:08 GMT</p>
<p>Content-Type: application/octet-stream</p>
<p>Content-Length: 4</p>
<p>Connection: keep-alive</p>
<p>Content-Disposition: attachment; filename="testwww-lmml-rutest"</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 write new buf t:1 f:0 09FADD74, pos 09FADD74, size: 233 file: 0, size: 0</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http write filter: l:0 f:0 s:233</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http output filter "/data/test.test?"</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http copy filter: "/data/test.test?"</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http postpone filter "/data/test.test?" BFEE6B08</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 write old buf t:1 f:0 09FADD74, pos 09FADD74, size: 233 file: 0, size: 0</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 write new buf t:0 f:1 00000000, pos 00000000, size: 0 file: 0, size: 4</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http write filter: l:1 f:0 s:237</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http write filter limit 0</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 writev: 233</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 sendfile: @0 4</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 sendfile: 4, @0 4:4</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http write filter 00000000</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http copy filter: 0 "/data/test.test?"</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http finalize request: 0, "/data/test.test?" a:1, c:2</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http request count:2 blk:0</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http finalize request: -4, "/data/test.test?" a:1, c:1</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 set http keepalive handler</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http close request</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http log handler</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 run cleanup: 09FACC2C</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 file cleanup: fd:14</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 free: 09FACCD8</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 free: 09FABCC0, unused: 4</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 free: 09FADCE0, unused: 3382</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 event timer add: 13: 65000:3477512305</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 free: 09FA3908</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 free: 09FA3500</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 hc free: 00000000 0</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 hc busy: 00000000 0</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 post event B7BAF070</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 delete posted event B7BAF070</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 http keepalive handler</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 malloc: 09FA3500:1024</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 recv: fd:13 -1 of 1024</p>
<p>2010/10/21 18:51:08 [debug] 28390#0: *4 recv() not ready (11: Resource temporarily unavailable)</p>
<p>2010/10/21 18:52:13 [debug] 28390#0: *4 event timer del: 13: 3477512305</p>
<p>2010/10/21 18:52:13 [debug] 28390#0: *4 http keepalive handler</p>
<div>2010/10/21 18:52:13 [debug] 28390#0: *4 close http connection: 13</div>
<div> </div>
<div>- видно, что получив ответ от FCGI, nginx правильно определил путь к файлу, но после этого почему-то вернул 404. Что происходит - понять не могу.</div>
<div> </div>
<div>При этом я ровно такую же схему совсем недавно уже реализовывал на другом серваке, и там все работало правильно. К сожалению, того сервера уже нет в живых, чтобы сравнить и понять, в чем отличие...</div>
<div> </div>
<div>Буду благодарен за любые конструктивные идеи и подсказки!</div>
<div> </div>
<div>Алекс Марртовский.</div></span>