<p id="rrtt5"></p><ruby id="rrtt5"></ruby>

      系統城裝機大師 - 唯一官網:www.1999hs.com!

      當前位置:首頁 > server > anz > 詳細頁面

      解決nginx 503 Service Temporarily Unavailable方法示例

      時間:2019-12-10來源:系統城作者:電腦系統城

      最近網站刷新后經常出現503 Service Temporarily Unavailable錯誤,有時有可以,聯想到最近在nginx.conf里做了單ip訪問次數限制,(limit_req_zone $binary_remote_addr zone=allips:20m rate=20r/s;) 把這個數量放大后在刷新發現問題解決。(還順便把這個改大了 limit_req zone=allips burst=50 nodelay;   )為了證實該問題,反復改動該數量測試發現問題確實在這。這個數量設得太小有問題,通過fiddler發現web頁面刷新一下,因為頁面上引用的js,css,圖片都算一個連接。所以單個頁面刷新下就有可能刷爆這個限制,超過這個限制就會提示503 Service Temporarily Unavailable。

      附上nginx.conf

      
       
      1. #user nobody;
      2. worker_processes 1;
      3. #worker_rlimit_nofile 100000;
      4. #error_log logs/error.log;
      5. #error_log logs/error.log notice;
      6. #error_log logs/error.log info;
      7.  
      8. #pid logs/nginx.pid;
      9.  
      10. events {
      11. worker_connections 1024;
      12. }
      13.  
      14. http {
      15. include mime.types;
      16. default_type application/octet-stream;
      17.  
      18. ##cache##
      19. proxy_connect_timeout 5;
      20. proxy_read_timeout 60;
      21. proxy_send_timeout 5;
      22. proxy_buffer_size 16k;
      23. proxy_buffers 4 64k;
      24. proxy_busy_buffers_size 128k;
      25. proxy_temp_file_write_size 128k;
      26. proxy_temp_path /home/temp_dir;
      27. proxy_cache_path /usr/local/nginx/cache levels=1:2 keys_zone=cache_one:200m inactive=1dmax_size=30g;
      28. ##end##
      29. #limit per ip per second access times 10
      30. limit_req_zone $binary_remote_addr zone=allips:20m rate=20r/s;
      31.  
      32. #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
      33. # '$status $body_bytes_sent "$http_referer" '
      34. # '"$http_user_agent" "$http_x_forwarded_for"';
      35.  
      36. #access_log logs/access.log main;
      37.  
      38. sendfile on;
      39. #tcp_nopush on;
      40.  
      41. #keepalive_timeout 0;
      42. keepalive_timeout 65;
      43.  
      44. #gzip on;
      45. upstream myweb80{
      46. ip_hash;
      47. server 192.168.3.105:80;
      48. server 192.168.3.103:80;
      49. }
      50.  
      51. upstream myweb8080{
      52. ip_hash;
      53. server 192.168.3.222:10080;
      54. #server 192.168.3.103:8080;
      55. }
      56. upstream myweb10086{
      57. ip_hash;
      58. server 192.168.3.102:10086;
      59. server 192.168.3.108:10086;
      60. }
      61. upstream myweb443{
      62. ip_hash;
      63. server 192.168.3.105:443;
      64. server 192.168.3.103:443;
      65. }
      66.  
      67. # another virtual host using mix of IP-, name-, and port-based configuration
      68. #
      69. server {
      70. listen 80;
      71. allow 218.17.158.2;
      72. allow 127.0.0.0/24;
      73. allow 192.168.0.0/16;
      74. allow 58.251.130.1;
      75. allow 183.239.167.3;
      76. allow 61.145.164.1;
      77. deny all;
      78. server_name myweb.com;
      79. location / {
      80. proxy_pass http://myweb80;
      81. proxy_set_header X-Real-IP $remote_addr;
      82. limit_req zone=allips burst=50 nodelay;
      83. }
      84. }
      85.  
      86. server {
      87. listen 8080;
      88. allow 218.17.158.2;
      89. allow 127.0.0.0/24;
      90. allow 192.168.0.0/16;
      91. allow 58.251.130.1;
      92. allow 183.239.167.3;
      93. allow 61.145.164.1;
      94. deny all;
      95. location / {
      96. proxy_pass http://myweb8080;
      97. proxy_set_header X-Real-IP $remote_addr;
      98. limit_req zone=allips burst=50 nodelay;
      99. }
      100. }
      101.  
      102. # HTTPS server
      103. #
      104. server {
      105. listen 10086 ssl;
      106. server_name localhost;
      107. allow 218.17.158.2;
      108. allow 127.0.0.0/24;
      109. allow 192.168.0.0/16;
      110. allow 58.251.130.1;
      111. allow 183.239.167.3;
      112. allow 61.145.164.1;
      113. #deny all;
      114. ssl_certificate ssl/1_www.myweb.com_bundle.crt;
      115. ssl_certificate_key ssl/2_www.myweb.com.key;
      116.  
      117. # ssl_session_cache shared:SSL:1m;
      118. # ssl_session_timeout 5m;
      119.  
      120. # ssl_ciphers HIGH:!aNULL:!MD5;
      121. # ssl_prefer_server_ciphers on;
      122.  
      123. location / {
      124. proxy_pass https:// myweb10086;
      125. #roft html;
      126. #index index.html index.htm;
      127. }
      128. }
      129.  
      130. 服務器{
      131. listen 443 ssl;
      132. server_name localhost;
      133.  
      134. ssl_certificate ssl / 1_www.myweb.com_bundle.crt;
      135. ssl_certificate_key ssl / 2_www.myweb.com.key;
      136.  
      137. #ssl_session_cache共享:SSL:1m;
      138. #ssl_session_timeout 5m;
      139.  
      140. #ssl_ciphers HIGH:!aNULL:!MD5;
      141. #ssl_prefer_server_ciphers on;
      142.  
      143. location / {
      144. proxy_pass https:// myweb443;
      145. #roft html;
      146. #roft html;
      147. #index index.html index.htm;
      148. }
      149. }
      150. }

      以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持我們。

      分享到:

      相關信息

      系統教程欄目

      欄目熱門教程

      人氣教程排行

      站長推薦

      熱門系統下載

      天堂资源中文WWW,久久精品女人天堂AV免费观看,无码专区一ⅤA亚洲V天堂,免费观看在线AⅤ天堂视频