解决nginx 503 Service Temporarily Unavailable方法示例

解决nginx 503 Service Temporarily Unavailable方法示例,第1张

解决nginx503ServiceTemporarilyUnavailable方法示例

本文的重点细节是处理nginx503服务暂时不可用的例子。原文根据示例代码非常详细,对大家的学习培训或者工作都有一定的参考价值。有必要的朋友陪我去了解一下。

最近网站更新后,503服务临时不可用经常是不正确的,有时是可能的。我觉得最近在nginx.conf里做了单ip浏览频率限制(limit_req_zone$binary_remote_addrzone=Allips:50mrate=20r/s;)增加这个总数后,在更新中解决问题。(还有顺便把这个改成limit_reqzone=allipsburst=50nodelay;)为了更好的确认问题,不断修改总数,在这里发现问题。这个小总数怎么了?按照fiddler的说法,网页是更新的。随着js、css和照片被引入网页,它们都算作一个链接。因此,刷新单个页面时,很可能会达到此限制。如果超过此限制,将会提醒503服务暂时不可用。

附加nginx.conf

#usernobody; worker_processes1; #worker_rlimit_nofile100000; #error_loglogs/error.log; #error_loglogs/error.lognotice; #error_loglogs/error.loginfo; #pidlogs/nginx.pid; events{ worker_connections1024; } http{ includemime.types; default_typeapplication/octet-stream; ##cache## proxy_connect_timeout5; proxy_read_timeout60; proxy_send_timeout5; proxy_buffer_size16k; proxy_buffers464k; proxy_busy_buffers_size129k; proxy_temp_file_write_size129k; proxy_temp_path/home/temp_dir; proxy_cache_path/usr/local/nginx/cachelevels=1:2keys_zone=cache_one:200minactive=1dmax_size=30g; ##end## #limitperippersecondaccesstimes10 limit_req_zone$binary_remote_addrzone=allips:50mrate=20r/s; #log_formatmain'$remote_addr-$remote_user[$time_local]"$request"' #'$status$body_bytes_sent"$http_referer"' #'"$http_user_agent""$http_x_forwarded_for"'; #access_loglogs/access.logmain; sendfileon; #tcp_nopushon; #keepalive_timeout0; keepalive_timeout65; #gzipon; upstreammyweb80{ ip_hash; server192.168.3.105:80; server192.168.3.103:80; } upstreammyweb8080{ ip_hash; server192.168.3.222:10080; #server192.168.3.103:8080; } upstreammyweb10086{ ip_hash; server192.168.3.102:10086; server192.168.3.108:10086; } upstreammyweb443{ ip_hash; server192.168.3.105:443; server192.168.3.103:443; } #anothervirtualhostusingmixofIP-,name-,andport-basedconfiguration # server{ listen80; allow218.17.158.2; allow127.0.0.0/24; allow192.168.0.0/16; allow58.251.130.1; allow183.239.167.3; allow61.145.164.1; denyall; server_namemyweb.com; location/{ proxy_passhttp://myweb80; proxy_set_headerX-Real-IP$remote_addr; limit_reqzone=allipsburst=50nodelay; } } server{ listen8080; allow218.17.158.2; allow127.0.0.0/24; allow192.168.0.0/16; allow58.251.130.1; allow183.239.167.3; allow61.145.164.1; denyall; location/{ proxy_passhttp://myweb8080; proxy_set_headerX-Real-IP$remote_addr; limit_reqzone=allipsburst=50nodelay; } } #HTTPSserver # server{ listen10086ssl; server_namelocalhost; allow218.17.158.2; allow127.0.0.0/24; allow192.168.0.0/16; allow58.251.130.1; allow183.239.167.3; allow61.145.164.1; #denyall; ssl_certificatessl/1_www.myweb.com_bundle.crt; ssl_certificate_keyssl/2_www.myweb.com.key; #ssl_session_cacheshared:SSL:1米; #ssl_session_timeout5m; #ssl_ciphersHIGH:!aNULL:!MD5; #ssl_prefer_server_cipherson; location/{ proxy_passhttps://myweb10086; #rofthtml; #indexindex.htmlindex.htm; } } 网络服务器{ listen443ssl; server_namelocalhost; ssl_certificatessl/1_www.myweb.com_bundle.crt; ssl_certificate_keyssl/2_www.myweb.com.key; #ssl_session_cache共享资源:SSL:1米; #ssl_session_timeout5m; #ssl_ciphersHIGH:!aNULL:!MD5; #ssl_prefer_server_cipherson; location/{ proxy_passhttps://myweb443; #rofthtml; #rofthtml; #indexindex.htmlindex.htm; } } }

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

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

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

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

发表评论

登录后才能评论

评论列表(0条)

保存