一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務器之家:專注于服務器技術及軟件下載分享
分類導航

云服務器|WEB服務器|FTP服務器|郵件服務器|虛擬主機|服務器安全|DNS服務器|服務器知識|Nginx|IIS|Tomcat|

服務器之家 - 服務器技術 - Nginx - 解決nginx 503 Service Temporarily Unavailable方法示例

解決nginx 503 Service Temporarily Unavailable方法示例

2020-03-12 14:22Jack2013tong Nginx

這篇文章主要介紹了解決nginx 503 Service Temporarily Unavailable方法示例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧

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

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

原文鏈接:https://blog.csdn.net/huwei2003/article/details/46743105

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 勾搭已婚高h| 亚洲精品123区在线观看 | 日本中文字幕不卡在线一区二区 | 扒开斗罗美女了的胸罩和内裤漫画 | 日韩一区二区三区免费 | 贰佰麻豆剧果冻传媒一二三区 | 国产精品天天影视久久综合网 | 亚洲美色综合天天久久综合精品 | 精品国产人妻国语 | 激情小说色图 | 国产福利视频一区二区微拍视频 | 青青色在线 | 美女认你摸 | 午夜影院小视频 | 俄罗斯年轻男同gay69 | 色图18p| 农村妇女野战bbxxx农村妇女 | 日本老妇乱子伦中文视频 | 蜜桃在线 | 好大好硬抽搐好爽想要 | 美女扒开尿口让男生添 漫画 | 成人免费在线视频观看 | 亚洲精品免费在线观看 | 性插图动态图无遮挡 | 高清色黄毛片一级毛片 | 精品久久久麻豆国产精品 | 欧美黑人ⅹxxx片 | 成人啪精品视频免费网站 | 99精品久久精品一区二区小说 | 禁止的爱善良的未删减版hd | 亚洲国产自 | 欧美在线一二三区 | 成人伊人青草久久综合网破解版 | 91九色麻豆| 国产日韩欧美在线一区二区三区 | xxxx泡妞中国 | 亚洲女同一区二区 | 国产小视频在线 | 欧美视频在线播放观看免费福利资源 | 99视频精品国在线视频艾草 | 草莓视频旧版 |