wget http://tengine.taobao.org/download/tengine-1.4.5.tar.gz;tar zxvf tengine-1.4.5.tar.gz;cd tengine-1.4.5;
./configure --with-openssl=***修改成openssl路径*** --with-pcre=***修改成pcre路径*** --with-zlib=***修改成zlib路径*** --with-http_upstream_check_module ;make && make install
vi /usr/local/nginx/conf/nginx.conf
proxy_cache_path /dev/shm/ngx levels=1:2 keys_zone=global:256m inactive=10m max_size=10m;
在http{}中添加 OSS后端池
upstream oss_backend {
server oss-internal.aliyuncs.com:80 max_fails=1 fail_timeout=3s;
server oss-internal.aliyuncs.com:8080 max_fails=1 fail_timeout=3s;
server oss.aliyuncs.com:80 max_fails=1 fail_timeout=3s;
server oss.aliyuncs.com:8080 max_fails=1 fail_timeout=3s;
keepalive_timeout 3600;
check interval=3000 rise=2 fall=1 timeout=1000;
}
server{
server_name lebastatic.vip.thiscache.com;
listen 80;
location /safe121/ { #此处的safe121要改成你的bucketname
expires 3650d; #缓存十年
proxy_pass http://oss_backend;
proxy_no_cache 0;
proxy_ignore_headers "Cache-Control" "Expires";
proxy_cache_valid 200 301 302 304 86400s;
proxy_cache_valid 403 404 400 500 10s;
proxy_cache_key $host$http_referer$uri$is_args$args$http_if_none_match$http_if_modified_since;
proxy_cache global;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; #当出现指定错误时,自动转发请求到下一个可用的后端
proxy_connect_timeout 1s;
proxy_read_timeout 2s;
add_header X-Thislan-Cache '$upstream_cache_status from $hostname';
}
}
/usr/local/nginx/sbin/nginx -s reload
集结各类场景实战经验,助你开发运维畅行无忧