小弟是一个牙医,最近业余时间开始迷恋nginx,做了一个简单的反向代理nytimes,但是图片无法显示。对方站的图片在graphics8.nytime.com,是akamai的cdn,我猜测nginx反代时直接解析对方ip,而直解析后的ip是无法访问akamai内容的,因此无法打开这些图片。不知道是不是这样,有没有什么解决办法呢?
server
{
listen 80;
server_name
news.xxx.org *.news.xxx.org;
if ( $host ~* (.*)\.(.*)\.(.*))
{
set $domain $1;
}
location /
{
proxy_pass
http://170.149.172.130;
proxy_set_header Host $host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
subs_filter 'www.nytimes.com' 'news.xxx.org' ig;
subs_filter 'graphics8.nytimes.com' 'graphics8.news.xxx.org' ig;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding ""; # GZIP
}
access_log off;
}
server
{
listen 80;
server_name
graphics8.news.xxx.org;
location /
{
proxy_pass
http://graphics8.nytimes.com;
proxy_set_header Host $host;
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 Accept-Encoding ""; # GZIP
}
access_log off;
}