扫码关注官方订阅号
域名直接指向A服务器,如果A服务器没有资源,则rewrite到B服务器,该如何设置?
location / { root /var/www/a.com if (!-e $request_filename) { proxy_pass http://b.com; proxy_store on; proxy_temp_path /var/www/a.com; } }
参考如下配置:
server { listen 80; server_name _; charset utf-8,gbk; #access_log logs/host.access.log main; location / { root /usr/share/nginx/html; index index.html index.htm; } error_page 404 /404.html; location = /404.html { rewrite ^(.*) http://www.xxx.com; } }
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
扫描下载App
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
location / {
root /var/www/a.com
if (!-e $request_filename) {
proxy_pass http://b.com;
proxy_store on;
proxy_temp_path /var/www/a.com;
}
}
参考如下配置:
server {
listen 80;
server_name _;
charset utf-8,gbk;
#access_log logs/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
error_page 404 /404.html;
location = /404.html {
rewrite ^(.*) http://www.xxx.com;
}
}