简体   繁体   English

NGINX是否可以向Unicorn重新发送请求?

[英]Is it possible for NGINX resend request to Unicorn?

我想知道是否有可能,如果我的NGINX向Unicorn发送了请求,而NGINX没有收到答复,NGINX是否可以再次将请求发送给Unicorn?

Not normally, no. 不正常,不。 I can think of a workaround, but I'm sure that I would advise it. 我可以考虑一种解决方法,但是我可以确定。 Using the Nginx upstream module you can define multiple upstream backend ends. 使用Nginx 上游模块,您可以定义多个上游后端。 Nginx has no way of knowing if the the different upstream servers listed are actually the same backend, nor does it care. Nginx无法知道列出的不同上游服务器是否实际上是相同的后端,也不在乎。 The docs for the upstream module say: " If an error occurs during communication with a server, the request will be passed to the next server." 上游模块的文档说: “如果在与服务器通信期间发生错误,则请求将被传递到下一个服务器。”

So if you arrange to have your app available at two different addresses (sockets, domain names, IPs or ports), then you can set Nginx to use the upstream module to try the same request twice. 因此,如果您打算在两个不同的地址(套接字,域名,IP或端口)上使用您的应用程序,则可以将Nginx设置为使用upstream模块尝试两次相同的请求。

If the the app was not responding properly in time the first time the request was made, there's a good chance it won't respond successfully on the follow-up request. 如果应用程序在第一次发出请求时未及时正确响应,则很有可能无法成功响应后续请求。 Using the upstream module in the intended way is recommended instead: Use two unique app servers, who might be sharing state through a backend resource like a database. 建议改用预期的方式使用upstream模块:使用两个唯一的应用服务器,它们可能通过后端资源(如数据库)共享状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM