Nginx 1.1.4可以使用HTTP1.1 keepalive指令服务上游连接,请参阅official documentation(它与keepalived客户端的连接不同).所以Unicorn配置如下所示:
upstream unicorn {
server unix:/tmp/unicorn.todo.sock fail_timeout=0;
keepalive 4;
}
server {
try_files $uri/index.html $uri @unicorn;
keepalive_timeout 70;
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
}
这些标头是HTTP连接所必需的:proxy_http_version和proxy_set_header.
所以问题是配置有效还是套接字本身是永久性的?
解决方法:
是的,它是有效的.在HTTP Keepalive方面,UNIX-socket和TCP / IP-socket之间没有区别.