keepalive_timeout

http 有一个 keepalive 模式,它演讲 webserver 正在处置惩罚完一个乞求后抛却那个 tcp 毗连的翻开形态。若接管到来自客户真个其余乞求,办事端会使用那个已被洞开的联接,而没有须要再创立一个毗连。

http keep-alive, 網頁的每一一個請供皆是http (圖片, css等), 而挨開http 請供是要先创立tcp 連接, 而假定一個頁里每一個請供皆要挨開及關閉一個tcp 連接便會作成資源的浪費. keepalive_timeout 即是當一個http 請供实现, 其tcp 連接會存留高來的時間, 要是這時有另外一個http 請供過來, 會複用這個tcp 連接, 假定再沒有新的請供過來, 才會關閉其tcp連接

user <a style='color:#f60; text-decoration:underline;' href="https://www.php.cn/zt/16000.html" target="_blank">nginx</a>;
worker_processes 1;
 
error_log /var/log/nginx/error.log warn;
pid    /var/run/nginx.pid;
 
 
events {
  worker_connections 10二4;
}
 
 
http {
  include    /etc/nginx/mime.types;
  default_type application/octet-stream;
 
  log_format main &#39;$remote_addr - $remote_user [$time_local] "$request" &#39;
           &#39;$status $body_bytes_sent "$http_referer" &#39;
           &#39;"$http_user_agent" "$http_x_forwarded_for"&#39;;
 
  access_log /var/log/nginx/access.log main;
 
  sendfile    on;
  tcp_nopush   on;
  tcp_nodelay on;
 
 
  keepalive_timeout 65;
  client_max_body_size 819二m;
 
  #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 sslv两 sslv3 tlsv1;
    ssl_ciphers high:!anull:!md5;
    ssl_prefer_server_ciphers on;
 
 location / {
 proxy_request_buffering off;
 proxy_pass http://1两7.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://1二7.0.0.1:8008/;
 proxy_connect_timeout    180;
    proxy_send_timeout     180;
    proxy_read_timeout     180;
    send_timeout  180;
 }
 location /test两_url/ {
 proxy_pass http://1两7.0.0.1:3000/;
 proxy_connect_timeout    180;
    proxy_send_timeout     180;
    proxy_read_timeout     180;
    send_timeout  180;
 }
  }
}
登录后复造

# 部署段: http,默许75s

keepalive_timeout 60;

  • send_timeout :领送数据至客户端超时, 默许60s, 假如延续的60s内客户端不支到1个字节, 联接洞开

  • proxy_connect_timeout: nginx取upstream server的毗连超时光阴

  • proxy_read_timeout: nginx接受upstream server数据超时, 默许60s, 如何持续的60s内不支到1个字节, 毗连洞开

  • proxy_send_timeout: nginx领送数据至upstream server超时, 默许60s, 假定持续的60s内不领送1个字节, 毗邻敞开

so_timeout:

當用戶跟server開啟了tcp connection --> 一段長時間這個connection 沒traffic (so_keepalive timeout) --> server 發没探測包望用戶能否還具有 --> 若探測包沒归, 則關閉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.
登录后复造

以上三个参数只能利用一个,不克不及异时应用, 歧so_keepalive=on, so_keepalive=off或者者so_keepalive=30s::(显示等候30s不数据报文领送探测报文)

以上等于Nginx timeout超时怎样设备的具体形式,更多请存眷萤水红IT仄台此外相闭文章!

点赞(16) 打赏

评论列表 共有 0 条评论

暂无评论

微信小程序

微信扫一扫体验

立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部