@
Deer404 location /tu/ {
limit_rate 1000k;
limit_rate_after 1000k;
valid_referers none blocked
baidu.com;
if ($invalid_referer) {return 403;} #rewrite ^/
http://www.domain.com/403.jpg;root /www/wwwroot/
baidu.com;
proxy_store on; # 开启本地缓存
proxy_store_access user:rw group:rw all:r;
proxy_temp_path cache_temp;
if ( $uri ~* "\.(gif|png|jpg|css|js|woff|woff2)$" )
{
expires 30d;
}
if (!-e $request_filename) {
proxy_pass
https://hk-baidu.oss-cn-hongkong-internal.aliyuncs.com;
}
}
我反代了内网地址,并选择保存文件到本地缓存。因为 OSS 走内网的话虽然不算流量费用,但有 get 请求费用,如果单页 get 数较高,PV 又高的话,就不友好了。
阿里云 HK 有 60G 硬盘,所以如果缓存住的话,就不会再产生 GET 费用了。
阿里云 HK 的全国速度挺稳定的,我一个北方联通都可以跑满 3.X MB/S ,后台看:
https://tutu.to/ttt_tpV7DC.png至于读写方面就不用太担心了,我目前的文章配图目录已经缓存了 32G 大小、57W 个文件,访问流畅丝滑。
https://tutu.to/ttt_s3JDVf.pnghttps://tutu.to/ttt_663vfN.png