nginx代理七牛云http资源,节省https费用(亲测有效)

七牛云https费用太高了,通过配置服务器https代理到http访问!

location ~ /qiniu/(.*) {
    proxy_pass http://qiniu.myweb.cn/$1;

 
    proxy_set_header Host $proxy_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;


}

这里手动加上了/qiniu/前缀,所以用$1代表(.*)里面匹配到的实际内容!


location ~ /attachment/(.*) {
    proxy_pass http://qiniu.myweb.cn$request_uri;

 
    proxy_set_header Host $proxy_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

这里如果没有加前缀,就直接用$request_uri代表实际的资源地址

1,配置在站点 jpg等资源文件匹配规则的前面,否则会被覆盖无法生效。

nginx代理七牛云http资源,节省https费用(亲测有效)_第1张图片

2,nginx的配置文件http{}块中,加上配置

    resolver 8.8.8.8 114.114.114.114 valid=600s ipv6=off;

否则会报错no resolver defined to resolve

valid表示dns解析缓存时间

ipv6=off表示,不支持ipv6地址

nginx代理七牛云http资源,节省https费用(亲测有效)_第2张图片

你可能感兴趣的:(http,nginx,https)