Nginx 配置 Google Fonts、Ajax 和 Gravatar 反向代理教程

mkdir -p /var/cache/nginx/cache
mkdir -p /var/cache/nginx/temp
修改 nginx 配置文件,加入

##
# Nginx Cache Settings
##

proxy_temp_file_write_size 128k;
proxy_temp_path /var/cache/nginx/temp;
proxy_cache_path /var/cache/nginx/cache levels=1:2 keys_zone=cache_one:50m inactive=7d max_size=5g;
以下是分别的配置文件

google-ajax.conf

upstream googleajax {
server ajax.googleapis.com:443;
}

server {
listen 80;

server_name ajax.css.network;

resolver 8.8.8.8;

location / {
proxy_pass_header Server;
proxy_set_header Host ajax.googleapis.com;
proxy_set_header Accept-Encoding '';
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_pass https://googleajax;
proxy_cache cache_one;
proxy_cache_valid 200 304 365d;
proxy_cache_key $host$uri$is_args$args;
expires max;
}
}

server {
listen 443 ssl spdy;

ssl on;
ssl_certificate /root/ssl/css.crt;
ssl_certificate_key /root/ssl/css.key;

ssl_prefer_server_ciphers on;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS !RC4";
keepalive_timeout 70;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;

server_name ajax.css.network;

resolver 8.8.8.8;

location / {
proxy_pass_header Server;
proxy_set_header Host ajax.googleapis.com;
proxy_set_header Accept-Encoding '';
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_pass https://googleajax;
proxy_cache cache_one;
proxy_cache_valid 200 304 365d;
proxy_cache_key $host$uri$is_args$args;
expires max;
}
}

阿里云海外IP地址

47.52.0.0-47.52.255.255
47.56.0.0-47.57.255.255
47.74.0.0-47.75.255.254
47.76.0.0-47.79.255.255
47.88.0.0-47.91.255.255
47.235.0.0-47.254.255.255
110.76.23.0-110.76.23.255
116.251.64.0-116.251.127.255
140.205.122.0-140.205.122.255
198.11.128.0-198.11.191.255
205.204.96.0-205.204.127.255