超时时间配置

超时时间配置,第1张

Nginxtimeout超时配置详解

本文详细介绍了Nginx超时请求超时的详细说明。原文根据示例代码非常详细,对大家的学习培训或者工作都有一定的参考价值。有必要的朋友陪我去了解一下。

最近的项目都采用nginx,后台管理用Java。发现其中一个需要后台管理来解决问题。一分钟过去了,结果要求状态码为504网关超时。

了解与nginx所有超时相关的设备,如下:

keepalive_timeout

HTTP有一个KeepAlive方法,它告诉web服务器在解决一个请求后保持这个TCP连接打开。如果从移动客户端收到其他请求,服务器将使用这个未关闭的连接,而不是创建另一个连接。

HTTPkeep-alive,一个网页的每一个请求都是HTTP(图片,CSS等。),而打开一个HTTP请求就是先创建一个TCP连接,如果一个页面的每一个请求都必须打开和关闭一个TCP连接,那就太浪费资源了。keepalive_timeout是当发出HTTP请求时,它的TCP连接会保持一段时间。如果此时出现另一个HTTP请求,这个TCP连接将被重用。如果没有新的请求,它的TCP连接将被关闭。

usernginx; worker_processes1; error_log/var/log/nginx/error.logwarn; pid/var/run/nginx.pid; events{ worker_connections1024; } http{ include/etc/nginx/mime.types; default_typeapplication/octet-stream; log_formatmain'$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.logmain; sendfileon; tcp_nopushon; tcp_nodelayon; keepalive_timeout65; client_max_body_size8191m; #gzipon; #include/etc/nginx/conf.d/*.conf; server{ listen80so_keepalive=30m::; listen443defaultssl; 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_timeout5m; ssl_protocolsSSLv2SSLv3TLSv1; ssl_ciphersHIGH:!aNULL:!MD5; ssl_prefer_server_cipherson; location/{ proxy_request_bufferingoff; proxy_passhttp://127.0.0.1:8011/; proxy_connect_timeout180; proxy_send_timeout180; proxy_read_timeout180; send_timeout180; } location/test1_url/{ proxy_passhttp://127.0.0.1:8008/; proxy_connect_timeout180; proxy_send_timeout180; proxy_read_timeout180; send_timeout180; } location/test2_url/{ proxy_passhttp://127.0.0.1:3000/; proxy_connect_timeout180; proxy_send_timeout180; proxy_read_timeout180; send_timeout180; } } }

#配备段:http,默认设置为75s

keepalive_timeout60

  • Send_timeout:向手机客户端发送数据的请求超时。默认设置是60秒。如果手机客户端在60s内没有收到一个字节,连接将被关闭。
  • proxy_connect_timeout:nginx和上游服务器之间的连接请求超时
  • Proxy_read_timeout:nginx在接受上游服务器数据信息请求时超时。默认设置是60秒。如果在60秒内没有收到字节,连接将被关闭。
  • proxy_send_timeout:nginx:nginx向上游服务器发送数据的请求超时,默认设置为60s。如果一个字节在60秒内没有被压入,连接将被关闭。
  • so_超时:

    当用户打开与服务器的TCP连接->:该连接长时间没有流量(so_keepalivetimeout>:服务器发送探测包查看用户是否还存在->:探测包不返回则关闭TCP连接。

    so_keepalive=on|off|[keepidle]:[keepintvl]:[keepcnt] so_keepalive=30m::10 willsettheidletimeout(TCP_KEEPIDLE)to30minutes,leavetheprobeinterval(TCP_KEEPINTVL)atitssystemdefault,andsettheprobescount(TCP_KEEPCNT)to10probes.

    只能应用上述三个主要参数中的一个,不能应用其他参数,如so_keepalive=on、so_keepalive=off或so_keepalive=30s::(表示等待30s后没有数据报文格式推送检测报文格式)

    文章里的内容就这些了。期待对大家的学习和培训有所帮助,也期待大家的应用。

    欢迎分享,转载请注明来源:内存溢出

    原文地址: https://outofmemory.cn/zz/774706.html

    (0)
    打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
    上一篇 2022-05-03
    下一篇 2022-05-03

    发表评论

    登录后才能评论

    评论列表(0条)

    保存