Quản trị net diễn đàn chia sẻ thông tin các thủ thuật mạng, internet bảo mật thông tin dành cho giới IT VIệt hy vọng là nơi bổ ích cho cộng đồng

Quản trị net diễn đàn chia sẻ thông tin các thủ thuật mạng, internet bảo mật thông tin dành cho giới IT VIệt hy vọng là nơi bổ ích cho cộng đồng (http://quantrinet.com/forum/index.php)
-   CDN (Content Delivery Network) (http://quantrinet.com/forum/forumdisplay.php?f=544)
-   -   How to create your own CDN server using Nginx (http://quantrinet.com/forum/showthread.php?t=9645)

hoctinhoc 17-06-2014 04:42 PM

How to create your own CDN server using Nginx
 
How to create your own CDN server using Nginx



Step1. install nginx.


yum install nginx

Step2. goto /etc/nginx/conf.d folder and backup all configuration files.


mkdir backups

mv *.conf backups

Step3. create a new file using:


vim pass.conf

Step4. Put following text into that file:


server {

listen 80;

server_name static.yourdomain.com;
location ~* \.(gif|jpg|jpeg|png|wmv|avi|mpg|mpeg|mp4|htm|html| js|css|mp3|swf|ico|flv)$ {
expires max;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://yourdomain.com;
proxy_ignore_headers X-Accel-Expires Expires Cache-Control;
proxy_store /var/www/cache$uri;
proxy_store_access user:rw group:rw all:r;
} }
Step5. save using :wand quit :q.


Step6. add nginx to startup services.


chkconfig nginx on

Step7. start nginx.


service nginx start

For this to work, you should create a cache folder under /var/www and it should have appropriate folder permissions for nginx to work.
You should add now forward all static resources to this server, if it is not found nginx will download file from server and cache it to its own cache directory.


Have fun.


References:

1. http://blog.unixy.net/2010/07/how-to...x-and-varnish/
2. http://www.cyberciti.biz/faq/install...g-yum-command/




:battay:


Bây giờ là 12:32 PM. Giờ GMT +7

Diễn đàn tin học QuantriNet
quantrinet.com | quantrimang.co.cc
Founded by Trương Văn Phương | Developed by QuantriNet's members.
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.