Nginx 反代 gravatar 头像完整配置文件

2015-04-13 13:17:16 +08:00
 xiqingongzi

Nginx反代gravatar头像,提供加速

公司要反代gravatar,搞完了把代码分享下,有兴趣的可以自己反代一个

需要编译proxy拓展

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
}
3399 次点击
所在节点    NGINX
9 条回复
lyragosa
2015-04-13 15:40:40 +08:00
我的网站是用php curl完成的,比较low
moliliang
2015-04-13 15:52:11 +08:00
server {
listen 80;
server_name gravatar.rkidc.net;

location / {
default_type text/html;
subs_filter_types text/css text/xml;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Referer http://2.gravatar.com;
proxy_set_header Host 2.gravatar.com;
proxy_pass http://2.gravatar.com;
proxy_set_header Accept-Encoding "";
}
}
moliliang
2015-04-13 15:53:04 +08:00
没注意看内容,以为lz是来求反代的。。。
moliliang
2015-04-13 15:54:49 +08:00
其实我自己的网站程序是通过代码直接get的,然后通过七牛镜像,就好了。。。
isayme
2015-04-13 16:06:04 +08:00
不是可以用多说的么?
djyde
2015-04-13 21:40:56 +08:00
我直接七牛反代
xiqingongzi
2015-04-15 12:42:00 +08:00
@isayme 公司想自己搞个。觉得多说太慢,而且不稳定
xiqingongzi
2015-04-15 12:42:13 +08:00
@lyragosa 也行啊,能实现就好
xiqingongzi
2015-04-15 12:43:59 +08:00
@moliliang 没找到类似的帖子,就自己发了个

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/183395

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX