own content delivery network CDN nginx

yum install nginx
cd /etc/nginx/conf.d

vi cdn.conf

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;
}
}

chkconfig nginx on
nginx -t
service nginx start

Leave a Reply

Your email address will not be published. Required fields are marked *