浏览 976
按点赞数排序
按时间排序
当出现下面这行命令行输出时,Nginx相当于启动失败,新配置文件未生效:
root@nginx-deployment-6686f596f-xhjt8:/etc/nginx/conf.d# nginx -t
2020/09/17 06:00:56 [emerg] 115#115: host not found in upstream "nginx2-deployment" in /etc/nginx/conf.d/default.conf:2
nginx: [emerg] host not found in upstream "nginx2-deployment" in /etc/nginx/conf.d/default.conf:2
nginx: configuration file /etc/nginx/nginx.conf test failed
如果新的配置文件生效,当Nginx连接nginx2-deployment时,在接收到RST报文、发生超时等,会重新选择到127.0.0.1:80这台server。
0
回答于2020-09-17 14:12
root@nginx-deployment-6686f596f-xhjt8:/etc/nginx/conf.d# nginx -t
2020/09/17 06:00:56 [emerg] 115#115: host not found in upstream "nginx2-deployment" in /etc/nginx/conf.d/default.conf:2
nginx: [emerg] host not found in upstream "nginx2-deployment" in /etc/nginx/conf.d/default.conf:2
nginx: configuration file /etc/nginx/nginx.conf test failed
root@nginx-deployment-6686f596f-xhjt8:/etc/nginx/conf.d# more default.conf
upstream test_upstream {
server nginx2-deployment;
server 127.0.0.1:80 backup;
}
server {
listen 80;
server_name nginx-test.ingageapp.com;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location /admin {
proxy_pass http://test_upstream;
}
@陶辉
0
回答于2020-09-17 14:02
可以将serviceB后加入backup选项,例如:
upstream test_default {
server serviceA;
server serviceB backup;
}
注意,不要使用hash类负载均衡算法,使用roundrobin、least conn等复制类扩展算法才有效。
另外,注意不要关闭next_upstream功能,而且http响应码、error、timeout已经配置到next_upstream中了。
0
回答于2020-09-17 13:55