cdn部署nginx如何配置
使用nginx部署cdn的方法如下:
upstream backend {server 1.1.1.1;
keepalive 128;
}
proxy_temp_path /dev/shm;
proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=cache_one:500m inactive=10d max_size=1024m;
limit_conn_zone $binary_remote_addr zone=addr:20m;
limit_req_zone $binary_remote_addr zone=req_addr:20m rate=200r/s;
server{
listen 80 ;
server_name www.iquduo.com;
access_log logs/e.cn.access.log main;
error_log logs/e.cn.error.log;
location ~* \.(aac|mp3|mp4|jpeg|jpg|png|gif|js|htm|html|css|avi|mpg|rar|wmv|doc|docx|mov|flv|pdf|edb|ppt|pptx)$ {
root /data/nginx/cache;
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
proxy_cache cache_one;
proxy_cache_valid 200 206 304 12h;
proxy_cache_revalidate on;
add_header X-Cache $upstream_cache_status;
add_header Via "CDN";
#limit_rate_after 4096k;
#limit_rate 2048k;
#limit_req zone=req_addr burst=300 nodelay;
#limit_req_status 503;
#proxy_limit_rate 256000; #64000 = 1Mb per connections
proxy_cache_key $scheme$proxy_host$uri;
proxy_cache_lock on;
proxy_cache_lock_timeout 10s;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://backend;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
location ~ / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://backend;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
}
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341