Caching servers in Local ISPs !!

shahzaib shahzaib shahzaib.cb at gmail.com
Mon Jun 16 17:18:57 UTC 2014


Hello itpp,i have been  abled to use ngx_http_geo_module. Now the request
coming from local ISP will first go to the main server (US) and then main
server will check if the ip is 1.2.3.4 so it'll direct the request to the
local caching server and than caching server will check if the file is
cached or it should again get the file from main server and cache it
locally.

When i tested it locally, it worked fine but the file URL in firebug is
coming from MAIN server when it should have come from the local caching
server. I can also see the caching directory size increases when the
matching client via geo module is directed to the local caching server but
the URL remains the same in firebug.

US config :-

geo $TW {
  default 0;
 192.168.1.0/24 1;
}



server {
        listen  80;
        server_name  002.files.com;
#       limit_rate 600k;
        location / {
            root   /var/www/html/files;
            index index.html index.htm index.php;
     #      autoindex on;
}


location ~ \.(mp4|jpeg|jpg)$ {
                mp4;
                root /var/www/html/files;

                 if ($TW) {
                        proxy_pass http://192.168.22.32:80;
                }

                expires 7d;
        valid_referers none blocked  domain.com *.domain.com blog.domain.com
*.facebook.com *.twitter.com *.files.com *.pump.net domain.tv *.domain.tv
domainmedia.tv www.domainmedia.tv embed.domainmedia.tv;
                if ($invalid_referer) {
                    return   403;
                }
                }
}

Edge config :-

proxy_ignore_headers "Set-Cookie";
proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=static:100m
                        loader_threshold=300 loader_files=10 inactive=1d
                        max_size=300000m;


proxy_temp_path /data/nginx/tmp 1 2;
add_header X-Cache-Status $upstream_cache_status;
 add_header Accept-Ranges bytes;
max_ranges 512;



server {

        listen       80;
        server_name  192.168.22.32;
        root /var/www/html/files;
        location ~ \.(mp4|jpeg|jpg)$ {
               root   /var/www/html/files;
                mp4;
                try_files $uri @getfrom_origin;

            }


        location @getfrom_origin {
        proxy_pass http://002.files.com:80;
        proxy_cache_valid 200 302   60m;
        proxy_cache_valid any 1m;
        proxy_cache static;
        proxy_cache_min_uses 1;
        }


Maybe i need to add some variable to get original server ip ?



<http://nginx.org/en/docs/http/ngx_http_geo_module.html>
<http://nginx.org/en/docs/http/ngx_http_geo_module.html>


On Fri, Jun 6, 2014 at 8:56 PM, shahzaib shahzaib <shahzaib.cb at gmail.com>
wrote:

> Thanks a lot itpp. :) I'll look into it and get back to you.
>
> Thanks again for quick solution :)
>
>
> On Fri, Jun 6, 2014 at 8:26 PM, itpp2012 <nginx-forum at nginx.us> wrote:
>
>> shahzaib1232 Wrote:
>> -------------------------------------------------------
>> > @itpp I am currenlty proceeding with proxy_cache method just because i
>> > had
>> > to done this in emergency mode due to boss pressure :-|. I have a
>> > quick
>> > question, can i make nginx to cache files for specific clients ?
>> >
>> > Like, if our caching servers are deployed by only single ISP named
>> > "ptcl".
>> > So if ip from ptcl client is browsing video, only his requested file
>> > should
>> > be cached not for any other client, does nginx support that ??
>>
>> You could do this based on some IP ranges or via
>> https://github.com/flant/nginx-http-rdns
>>
>> See
>>
>> http://serverfault.com/questions/380642/nginx-how-to-redirect-users-with-certain-ip-to-special-page
>> and
>>
>> http://www.cyberciti.biz/faq/nginx-redirect-backend-traffic-based-upon-client-ip-address/
>>
>> Posted at Nginx Forum:
>> http://forum.nginx.org/read.php?2,249997,250707#msg-250707
>>
>> _______________________________________________
>> nginx mailing list
>> nginx at nginx.org
>> http://mailman.nginx.org/mailman/listinfo/nginx
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20140616/2a642e1b/attachment-0001.html>


More information about the nginx mailing list