server
{
listen 80;
server_name A1.com www.A1.com;
if ( $scheme = http ){
return 301 https://$server_name$request_uri;
}
if ($http_user_agent ~* (baiduspider|360spider|haosouspider|googlebot|soso|bing|sogou|yahoo|sohu-search|yodao|YoudaoBot|robozilla|msnbot|MJ12bot|NHN|Twiceler)) {
return 403;
}
location /
{
proxy_pass http://A2.com;
proxy_set_header Host A2.com;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_cache_key A2.com$request_uri$is_args$args;
proxy_cache_valid 200 304 301 302 1h;
add_header X-Cache $upstream_cache_status;
proxy_set_header Accept-Encoding "";
sub_filter "A2.com" "A1.com";
sub_filter_once off;
expires 12h;
}
location ~ .*.(php|jsp|cgi|asp|aspx|flv|swf|xml)?$
{
proxy_set_header Host A2.com;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://A2.com;
proxy_set_header Accept-Encoding "";
sub_filter "A2.com" "A1.com";
sub_filter_once off;
}
access_log /root/log/1.com.log;
}