Nginx timeout timeout configuration details

  • 2020-05-24 06:53:44
  • OfStack

Recently, nginx was used in the project, while Java was used in the background. It was found that one request was processed in the background for one minute, and the result was that the request Status Code was 504 Gateway Time-out.

Understand all the timeout configuration related to nginx, as follows:

keepalive_timeout

HTTP has an KeepAlive mode, which tells webserver to keep the TCP connection open after processing one request. If another request is received from the client, the server will take advantage of the connection that has not been closed without having to make another connection.

If each of the first ACTS of the first act is to play the first act of the first act, the first act is to play the first act of the first act of the first act. If the first act of the first act is to play the first act of the first act of the first act, the second act is to play the first act of the first act. An TCP mobile phone can be used to connect a mobile phone. If a new mobile phone is used, an TCP mobile phone can be used to connect the mobile phone


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 is 75s

keepalive_timeout 60;

send_timeout: send data to client timeout, default is 60s, if the client in continuous 60s does not receive 1 byte, the connection is closed proxy_connect_timeout: connection timeout for nginx and upstream server proxy_read_timeout: nginx receives upstream server data timeout, default is 60s, if no 1 byte is received in a continuous 60s, the connection is closed proxy_send_timeout: nginx sends data to upstream server timeout, default is 60s, if no 1 byte is sent within continuous 60s, the connection is closed

so_timeout:

TCP CONNECTION -- was used with SERVER > En 81en (so_keepalive timeout) -- > The SERVER mobile app can be viewed to see if the mobile app exists > If you want to retrieve a mobile phone, you can also retrieve a mobile phone with TCP CONNECTION


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.

For example, so_keepalive=on, so_keepalive=off, or so_keepalive=30s: (means waiting for 30s to send probe message without data message)


Related articles: