I recently used nginx in a project, and used Java in the backend. I found that one request took more than 1 minute to process in the backend, and the request Status Code was 504 Gateway Time-out. Understand all the timeout-related configurations of nginx, as follows: keepalive_timeout HTTP has a KeepAlive mode, which tells the webserver to keep the TCP connection open after processing a request. If other requests are received from the client, the server will use this unclosed connection without establishing another connection. http keep-alive, every request of a web page is HTTP (images, CSS, etc.), and opening an HTTP request requires establishing a TCP connection first. If a page has to open and close a TCP connection for each request, it will be a waste of resources. keepalive_timeout is the time that the TCP connection will remain when an HTTP request is completed. If another HTTP request comes at this time, the TCP connection will be reused. If there is no new request, the TCP connection will be closed. user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; client_max_body_size 8192m; #gzip on; #include /etc/nginx/conf.d/*.conf; server { listen 80 so_keepalive=30m::; listen 443 default ssl; ssl_certificate /etc/nginx/ssl/server.crt; ssl_certificate_key /etc/nginx/ssl/portalkey.key; #ssl_password_file /etc/nginx/ssl/ssl.pass; ssl_session_timeout 5m; ssl_protocols SSLv2 SSLv3 TLSv1; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { proxy_request_buffering off; proxy_pass http://127.0.0.1:8011/; proxy_connect_timeout 180; proxy_send_timeout 180; proxy_read_timeout 180; send_timeout 180; } location /test1_url/ { proxy_pass http://127.0.0.1:8008/; proxy_connect_timeout 180; proxy_send_timeout 180; proxy_read_timeout 180; send_timeout 180; } location /test2_url/ { proxy_pass http://127.0.0.1:3000/; proxy_connect_timeout 180; proxy_send_timeout 180; proxy_read_timeout 180; send_timeout 180; } } } # Configuration section: http, default 75s keepalive_timeout 60;
so_timeout: When a user opens a TCP connection with a server --> there is no traffic on this connection for a long time (so_keepalive timeout) --> the server sends a probe packet to see if the user is still alive --> if there is no response to the probe packet, the TCP connection is closed so_keepalive=on|off|[keepidle]:[keepintvl]:[keepcnt] so_keepalive=30m::10 will set the idle timeout (TCP_KEEPIDLE) to 30 minutes, leave the probe interval (TCP_KEEPINTVL) at its system default, and set the probes count (TCP_KEEPCNT) to 10 probes. Only one of the above three parameters can be used, and they cannot be used at the same time, such as so_keepalive=on, so_keepalive=off or so_keepalive=30s:: (which means waiting for 30 seconds without data packets to send a detection packet) The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: 13 Most Frequently Asked Vue Modifiers in Interviews
>>: How to correctly modify the ROOT password in MySql8.0 and above versions
Let our users choose whether to move forward or ba...
Introduction In a production environment, in orde...
<div class="sideBar"> <div>...
1. Introduction to LVM When we manage Linux disks...
Preface I recently sorted out my previous notes o...
/****************** * Kernel debugging technology...
Preface This control will have a watermark at the...
Whitespace rules in HTML In HTML, multiple spaces...
Table of contents 1. What is deconstruction? 2. A...
Table of contents Union query 1. Query the ID and...
Table of contents 1. Monitoring port Relationship...
Table of contents Why use gzip compression? nginx...
Preface Project requirements: Install the Docker ...
Before learning awk, we should have learned sed, ...
Table of contents 1. What is redux? 2. The princi...