rclon commited on
Commit
ab2ec24
1 Parent(s): ba85f57

Update nginx.conf

Browse files
Files changed (1) hide show
  1. nginx.conf +15 -3
nginx.conf CHANGED
@@ -21,7 +21,7 @@ http {
21
  # 连接超时设置
22
  keepalive_timeout 65;
23
  keepalive_requests 100;
24
-
25
  # 压缩设置
26
  gzip on;
27
  gzip_vary on;
@@ -32,7 +32,9 @@ http {
32
  # 日志配置
33
  access_log /tmp/nginx_access.log;
34
  error_log /tmp/nginx_error.log;
35
-
 
 
36
  # MIME类型
37
  include /etc/nginx/mime.types;
38
 
@@ -52,7 +54,8 @@ http {
52
 
53
  location /hf/ {
54
  rewrite ^/hf/(.*)$ /$1 break;
55
-
 
56
  proxy_pass http://backend;
57
  proxy_set_header Upgrade $http_upgrade;
58
  proxy_set_header Connection "upgrade";
@@ -74,9 +77,12 @@ http {
74
  proxy_connect_timeout 60s;
75
  proxy_send_timeout 60s;
76
  proxy_read_timeout 60s;
 
77
  }
78
 
79
  location / {
 
 
80
  proxy_pass http://backend;
81
  proxy_set_header Upgrade $http_upgrade;
82
  proxy_set_header Connection "upgrade";
@@ -98,6 +104,12 @@ http {
98
  proxy_connect_timeout 60s;
99
  proxy_send_timeout 60s;
100
  proxy_read_timeout 60s;
 
 
 
 
 
 
101
  }
102
  }
103
  }
 
21
  # 连接超时设置
22
  keepalive_timeout 65;
23
  keepalive_requests 100;
24
+
25
  # 压缩设置
26
  gzip on;
27
  gzip_vary on;
 
32
  # 日志配置
33
  access_log /tmp/nginx_access.log;
34
  error_log /tmp/nginx_error.log;
35
+
36
+ limit_req_zone $binary_remote_addr zone=one:10m rate=10r/s;
37
+ limit_conn_zone $binary_remote_addr zone=addr:10m;
38
  # MIME类型
39
  include /etc/nginx/mime.types;
40
 
 
54
 
55
  location /hf/ {
56
  rewrite ^/hf/(.*)$ /$1 break;
57
+ limit_req zone=one burst=15 nodelay;
58
+ limit_conn addr 5;
59
  proxy_pass http://backend;
60
  proxy_set_header Upgrade $http_upgrade;
61
  proxy_set_header Connection "upgrade";
 
77
  proxy_connect_timeout 60s;
78
  proxy_send_timeout 60s;
79
  proxy_read_timeout 60s;
80
+ error_page 503 =429 /429.html;
81
  }
82
 
83
  location / {
84
+ limit_req zone=one burst=20 nodelay;
85
+ limit_conn addr 10;
86
  proxy_pass http://backend;
87
  proxy_set_header Upgrade $http_upgrade;
88
  proxy_set_header Connection "upgrade";
 
104
  proxy_connect_timeout 60s;
105
  proxy_send_timeout 60s;
106
  proxy_read_timeout 60s;
107
+
108
+ error_page 503 =429 /429.html;
109
+ }
110
+ # 429 错误页面
111
+ location = /429.html {
112
+ return 429 'Too Many Requests';
113
  }
114
  }
115
  }