did you enable it in nginx with the configurations explained in their wiki ?

On Wednesday, September 25, 2013 5:53:05 PM UTC+2, Tito Garrido wrote:
>
> Hi Niphlod!
>
> I am using nginx as server and when I tried to use:
>
> response.headers['X-Accel-Redirect'] = os.path.join(request.folder, 
> 'uploads', document.file)
> return ''
> mine is:
>
> *...
> path = splits[0] + '.' + splits[1] + '/' + splits[2][:2] + '/'
> global_path = path + image
> filename = os.path.join(request.folder,'uploads',global_path)
> response.headers['X-Accel-Redirect'] = filename
> *
> *return ''*
>
> *filename is returning: 
> "/home/www-data/web2py/applications/indiana/uploads/site.logo_montadora/b6/site.logo_montadora.b67dbafcc4aa040e.666f72642e6a7067.jpg"
> *
>
> It raises error 404. I have checked the path:
> www-data@li69-46:/$ ls -alh 
> /home/www-data/web2py/applications/indiana/uploads/site.logo_montadora/b6/site.logo_montadora.b67dbafcc4aa040e.666f72642e6a7067.jpg
> -rw-r--r-- 1 www-data www-data 31K Aug 16 11:04 
> /home/www-data/web2py/applications/indiana/uploads/site.logo_montadora/b6/site.logo_montadora.b67dbafcc4aa040e.666f72642e6a7067.jpg
>
> And www-data user is able to read it... Am I doing something wrong?
>
> Do I need to enable anything on nginx side?
> 2.5.1-stable+timestamp.2013.06.06.15.39.19
> (Running on nginx/1.1.19) 
>
> Thanks in advance!
>
> Tito
>
>
>
> On Thu, Aug 22, 2013 at 5:31 PM, Niphlod <nip...@gmail.com 
> <javascript:>>wrote:
>
>> uhm. download() lets web2py stream the file instead of nginx. 
>> fast_download() too, it just skips the part that handles the authorization 
>> logic and adds correct cache headers, but this will lead to faster loading 
>> of pages from the 2nd time the user accesses the page: it won't change a 
>> thing in the 1st request.
>>
>> Why don't you just put those images in "static/something" ?
>>
>> The other very smart thing to do is using http://wiki.nginx.org/X-accel. 
>> This basically enables nginx to "intercept" an empty page with some 
>> special headers (so web2py does it without even accessing the file) and 
>> take care of serving the file instead of your application. This will 
>> probably speed up your 1st request (and releaves some pressure from the 
>> web2py process), but the hard-limit of bandwith will of course remain 
>> there, no matter what.
>>
>> Your fast download will then kinda look like 
>> def fast_download():
>>     ....
>>
>>     filename = os.path.join(request.folder,'uploads',request.args(0))
>>
>>     response.headers['X-Accel-Redirect'] = os.path.join(request.folder, 
>> 'uploads', document.file)
>>      return ''
>>
>>
>>
>> On Thursday, August 22, 2013 10:06:34 PM UTC+2, Adi wrote:
>>>
>>>
>>>
>>> Hello everyone.
>>>
>>> Am trying to populate a page with around 20 dynamic images from the 
>>> upload folder, but they get rendered extremely slow, even as thumbnails. 
>>> Tried using a suggest approach from the forum "fast_download()", but 
>>> without luck in my case. 
>>>
>>> Anyone has a suggestion, what should I be looking at, and how to improve 
>>> the speed of loading dynamic images? 
>>>
>>> Platform: clean ubuntu node with web2py and nginx (no caching setup, 1Gb 
>>> of ram). Nothing else is running on it.
>>>
>>> Performed following three tests:
>>>
>>> Regular download():
>>> Compressed images (through PIL, with extension .thumbnail): 
>>> http://www.webpagetest.org/**result/130822_1F_WAD/<http://www.webpagetest.org/result/130822_1F_WAD/>(500Kb
>>>  in 25 sec)
>>> Regular size images: 
>>> http://www.webpagetest.org/**result/130822_5K_ZSX/<http://www.webpagetest.org/result/130822_5K_ZSX/>(3Mb
>>>  in 26 sec)
>>>
>>> Fast_Download() with regular size images:
>>> http://www.webpagetest.org/**result/130822_C3_1008/<http://www.webpagetest.org/result/130822_C3_1008/>(3Mb
>>>  in 28 sec)
>>>
>>> Tried to implement caching in nginx site config, but that disabled 
>>> images completely, and I couldn't get it to work:
>>>
>>> #location ~* ^.+\.(jpg|jpeg|gif)$ {
>>> #   root         /home/www-data/web2py/**applications/;
>>> #   access_log   off;
>>> #   expires      30d;
>>> #}
>>>
>>> or 
>>>
>>> #location ~* \.(jpg|jpeg|gif|png|css|js|**ico|xml)$ {
>>>  #    access_log off;
>>>  #    log_not_found off;
>>>  #    expires 180d;
>>>  #}
>>>
>>> Fast download used: 
>>> def fast_download():
>>>     session.forget(response)
>>>     cache.action(time_expire=60480**0)(lambda: 0)()
>>>
>>>     # very basic security (only allow fast_download on 
>>> your_table.upload_field):
>>>     if not request.args(0).startswith("**product.image"):
>>>     return download()
>>>
>>>     filename = os.path.join(request.folder,'**uploads',request.args(0))
>>>
>>>     return response.stream(open(filename,**'rb'))
>>>
>>>
>>> Segment of the code that displays the images:
>>>
>>>                         <div id="prod_img" itemprop="image">
>>>                             {{if p.image:}}
>>>                                 <a href="{{=product_link}}">
>>>                 {{
>>>                 #big_regex = re.compile('|'.join(map(re.**escape, 
>>> IMAGE_EXTENSIONS)))
>>>                 #tmb_image = big_regex.sub(INDEX_TMB, p.image)
>>>                 }}
>>>                                 <img src="{{=URL('download', 
>>> args=p.image, scheme=True, host=True)}}" 
>>>                     alt="{{=product_name}}" href="{{=product_link}}" 
>>> height="180px" width="160px"/>
>>>                                 </a>
>>>                             <img data-src='{{=tmb_image}}' >
>>>                                 {{pass}}
>>>                         </div>
>>>
>>>
>>>
>>>
>>>  
>>>
>>  -- 
>>  
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to web2py+un...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> -- 
>
> Linux User #387870
> .........____
> .... _/_õ|__|
> ..º[ .-.___.-._| . . . .
> .__( o)__( o).:_______ 
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to