域名直接指向A服务器,如果A服务器没有资源,则rewrite到B服务器,该如何设置?
地点 / { 根 /var/www/a.com if (!-e $request_filename) { proxy_pass http://b.com; proxy_store 上; proxy_temp_path /var/www/a.com; } }
参考如下配置:
服务器{ 听80; 服务器名称_; 字符集 utf-8,gbk; #access_log 日志/host.access.log main; 地点 / { 根 /usr/share/nginx/html; 索引index.htmlindex.htm; } error_page 404 /404.html; 位置= /404.html { 重写 ^(.*) http://www.xxx.com; } }
地点 / {
根 /var/www/a.com
if (!-e $request_filename) {
proxy_pass http://b.com;
proxy_store 上;
proxy_temp_path /var/www/a.com;
}
}
参考如下配置:
服务器{
听80;
服务器名称_;
字符集 utf-8,gbk;
#access_log 日志/host.access.log main;
地点 / {
根 /usr/share/nginx/html;
索引index.htmlindex.htm;
}
error_page 404 /404.html;
位置= /404.html {
重写 ^(.*) http://www.xxx.com;
}
}