技术解析
公司要反代gravatar,搞完了把代码分享下,有兴趣的可以自己反代一个
proxy_cache_path /home/wwwroot/example.com/cache levels=1:2 keys_zone=gravatar:10m inactive=7d max_size=1g;
server
{
listen 80;
server_name example.com
location / {
proxy_cache gravatar;
proxy_cache_valid 200 302 1h;
proxy_cache_valid 404 1m;
proxy美国服务器_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_pass https://secure.gravatar.com;
proxy_set_header Host "secure.gravatar.com";
proxy_set_header Accept-Encoding "";
proxy_set_header User-Agent $http_user_agent;
}
access_log off; #access_log end
error_log /dev/null; #error_log end
}