![Nginx 反向代理 - 绕过带有 404 代码的服务器](https://linux22.com/image/694190/Nginx%20%E5%8F%8D%E5%90%91%E4%BB%A3%E7%90%86%20-%20%E7%BB%95%E8%BF%87%E5%B8%A6%E6%9C%89%20404%20%E4%BB%A3%E7%A0%81%E7%9A%84%E6%9C%8D%E5%8A%A1%E5%99%A8.png)
我想知道是否有办法设置 NGINX 反向代理来“绕过”以 404(或其他错误代码)响应的列表中的服务器。
我有一个集群图像板,我正在通过 6 台专用服务器批量导入图像,这些服务器不属于集群,因为它们不使用共享存储。当图像导入实时系统时,集群中的其他服务器显然会响应 404,因为它们无法访问位于导入服务器上的文件。
有没有办法可以将它们添加到 NGINX 上的列表中,并且它会忽略以 404 响应的服务器并使用正确响应的服务器?
我的 NGINX 反向代理配置:
upstream sequenzia-press {
# server node-end1:80;
server node1:80;
server node2:80;
server node3:80;
server node4:80;
}
upstream sequenzia-cpu {
server node1:80;
server node2:80;
server node3:80;
server node4:80;
}
server {
listen 80;
root /var/www/html;
server_name sequenzia.acr.moe;
rewrite ^ https://$server_name$request_uri? permanent;
}
server {
listen 443 ssl;
root /var/www/seq;
server_name sequenzia.acr.moe;
ssl_certificate /etc/apache2/keyset/fullchain.pem;
ssl_certificate_key /etc/apache2/keyset/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers RC4:HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
keepalive_timeout 70;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
client_max_body_size 500M;
location / {
add_header TangledFramework-Proxy-Datacenter Nagatenjouki/Core-MD;
add_header TangledFramework-Proxy-Network Nagatenjouki/Production;
add_header TangledFramework-Proxy-Transit Nagatenjouki/Shirai;
add_header TangledFramework-Proxy-Service Sequenzia_Delivery;
proxy_pass http://sequenzia-cpu$request_uri;
}
location /post/import {
add_header TangledFramework-Proxy-Datacenter Orion/Endymion-ATL-1;
add_header TangledFramework-Proxy-Network Orion-Edge-CDN/Primary;
add_header TangledFramework-Proxy-Transit Orion-Edge-A/Shirai-1;
add_header TangledFramework-Proxy-Service Sequenzia_Delivery;
proxy_pass http://<Import RPC>$request_uri;
}
location /data {
add_header TangledFramework-Proxy-Datacenter Orion/Endymion-ATL-1;
add_header TangledFramework-Proxy-Network Orion-Edge-CDN/Primary;
add_header TangledFramework-Proxy-Transit Orion-Edge-A/Shirai-1;
add_header TangledFramework-Proxy-Service Sequenzia_Delivery;
proxy_pass http://sequenzia-press$request_uri;
}
location /se4trp {
root /var/www/err;
expires max;
}
}