Step1. Install nginx on your hosting server.
yum install nginxStep2. goto
/etc/nginx/conf.d
folder and backup all configuration files.mkdir backups mv *.conf backupsStep3. Create a new configuration file using:
vim pass.confStep4. 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 nginx configuration using
:wq
and quit.Step6. Add nginx to startup services.
chkconfig nginx onStep7. Start nginx.
service nginx startFor this configuration to work, you should create a cache folder under /var/www and it should have appropriate folder permissions for nginx to work.
You should now forward all static resources to this server. If the file is not found, nginx will download the file from your primary server and it will cache the file to its own cache directory.
Have fun.
Source URL: http://metinsaylan.com/6065/create-cdn-server-using-nginx/
0 comments:
Post a Comment