alcina
July 14, 2013, 2:31pm
#1
Hello,
My problem is very simple, I’d like to change from php readfile to
x-accel-redirect. I know exactly how to do it, but I have a problem:
My files are organized like that:
/home/ID(id of directory on mysql)/ .mp3 .xml and .zip/.rar
I would like to serve the .zip or .rar files by php, but .xml and .mp3
needs
to be allowed from accessing directly. When I put /home/ID as internal,
isn’t possible access the .xml or .mp3 files.
What I need to do to have the xml and mp3 files being accessed directly
and
zip/rar by x-accel-redirect ON THE SAME directory?
Any help is appreciated, thanks!
Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,240827,240827#msg-240827
Hello!
On Sun, Jul 14, 2013 at 08:30:38AM -0400, jordanmoreira57 wrote:
isn’t possible access the .xml or .mp3 files.
What I need to do to have the xml and mp3 files being accessed directly and
zip/rar by x-accel-redirect ON THE SAME directory?
Try something like this:
location /directory/ {
location ~ \.(xml|mp3)$ {
# accessible
}
location ~ \.(zip|rar)$ {
internal;
}
}
–
Maxim D.
http://nginx.org/en/donation.html
Everything appears to be as you asked for. Did you perhaps forget your
“Content-Disposition” header?
Jonathan
Jonathan M.
Oxford, London, UK
http://www.jpluscplusm.com/contact.html
I tried something like that:
default.conf:
location / {
root /home/;
index index.html index.htm index.php;
location ~ \.(zip|rar)$ {
internal;
}
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
teste.php:
<?php
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-type: application/octet-stream");
header('X-Accel-Redirect: /799/WESLEY SAFADAO BANDA GAROTA SAFADA NO
FORRICO
EM ICOCE 13072013 by WWWANDRECDCOM.zip');
?>
Apparently the file was acessed but the download don’t started, see what
was
shown on browser:
"PK ÊzîBLWESLEY SAFADAO & BANDA GAROTA SAFADA 2013 - FORRICO 2013 by
WWW.ANDRECD.COM/UXSàâQ\ìâQõPK {îB›WESLEY SAFADAO & BANDA GAROTA
SAFADA 2013 - FORRICO 2013 by WWW.ANDRECD.COM/01 - WWW.ANDRECD.COM -
Wesley
Safadao & Banda Garota Safada no Forrico
2013.mp3UXÉìâQÉìâQõì¹eTœM·-ÚxÐàî4îÜÝÝi—F ¸»5Ü÷àî î[email protected]
9¼ßþÎÞwœ{þí;î½cœÌ5ž¹ªV¯YOUý˜Õ Í´ d4ÿa/‹ƒ“ --¡ýŸ“
,£úÂ_ý3.È-ÈËЖQ•z‰¨_š–‹§³5¥¬‹;ȆRÝÝ…’“ƒ‹ƒ’QÒìhMÉÉPWÀyœ½ä‚,@6ìö®6
—àÏòŸïlEYYÀúåø³…½/ã¶TTÌÿÒD„À¿0Ô—@1 @|áp/;;矒À?& ¼ôa¼Äb/
@vüïùþÅ_üÅ_üÅ_üÅÿ‘ð;;yz€^(R<¿¼þ‹g(ˆGüOÞ”˜ð/ŽÀÃ$&þÿ/ñ*õŸZ}Å_üÅ_üÅ_üÅÿÙøç§!N!NAÊÂ+
Ä!ð¿í{q 0Ààðx¼°ŒÈŸ-tR;ÄUˆÝÙƒÍÂÚÅÒ†ÍÊʼnÝÇ•“ƒ
"îãjaå¡´´E.Ú»(ÁÖ¢z¼**®R6v
y?w-?Um+?+Akq1L4!'W’ˆ¥“£³‡(õ¿ª½ðºÙ©ÅDÜm…4¥eÿñ‰Rÿ{.ÞÞÞlÞÜl.î
vNAAAv.v…àKÐÃ×bátö ùwi+w°+ìâLùOlaéâ ¥öô[ÙZØòZZ[󖸜œÖ@knN
57·5?/§—-§%õ¿åþSÝÕÓÝñ_ÚÖVì6Ž6N6ΗÕàd§fÿVóe‰þSô»ü/ïø’#$ånc±‘~ibÿl,ƒÈ)¨ý?7–‡‡ „ýÉaÿ_&úÿÁj‰‰X[
Yý3’÷ÿײqûïí¶#XìÚèÿx׎ÿ
/¥_Î**ªûÿUõÿ¾ìÿ>v/ì?éË7)ÿ_À_‘¿"EþŠüù+òWäÿ_"ÿetmœ_Ü÷‹ý³úç/Áÿþ)òß÷§€ó
pG €ÇCÀûÓ ààQààþë*€„ˆ€[email protected] …Їþ’
ýÁààáQ‘ÑÐáà‘Qppñ^áP
¨Ð©9i$ˆh5,Þ“Ðqéº%ÌÐ3h&Cçxø¤´u,mƒ“R{gùÃæ%eÝ—^J’ÿ3ªþ—Ü‹""ò+$Ô—aMœBd$$$dtd”—Q §<¢†…rn´î
uïÌ+|ÉK.Ë`“M÷>TÂ746¶É)õ³óÄ<üRÒ©rÚz^a”
Just stranger characters.
Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,240827,240835#msg-240835