Get the App
SLTechnology News&Howtos  ›  Development  › 

How does nginx upstream turn on keepalive

Shulou Source: shulou.com Published: 2022-06-01 04:09:10 11月12日 Update

This article mainly shows you "nginx upstream how to open keepalive", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "nginx upstream how to open keepalive" this article.

Nginx upstream enables keepalive

Upstream tomcat {server ops-coffee.cn:8080; keepalive 1024;} server {location / {proxy_http_version 1.1; proxy_set_header Connection "; proxy_pass http://tomcat;}}

Nginx is used as a reverse proxy in most cases in the project, such as nginx followed by tomcat,nginx followed by php, etc. When we enable keepalive between nginx and back-end services, we can reduce the resource consumption caused by frequent creation of TCP connections, as above

Keepalive: specifies that the maximum number of connections that can be maintained by each nginxworker is 1024, which is not set by default, that is, keepalive does not take effect when nginx is used as client.

Proxy_http_version 1.1: enabling keepalive requires the HTTP protocol version to be HTTP 1.1

Proxy_set_header Connection "": in order to be compatible with the old protocols and to prevent keepalive failure caused by Connection close in the http header, the Connection in the HTTP header needs to be cleared in time.

The above is all the content of the article "how to start keepalive with nginx upstream". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Content articles learning help maximum frequent between headers such as above situation quantity easy to understand more organization version knowledge editing industry resources information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Microsoft MariaDB macOS Shulou Tech Info