我已经在nginx.conf中将max_fails=2
和fail_timeout=10s
设置为nginx上游,但是此配置无效。
user admin;
worker_processes auto;
error_log /var/log/nginx/error.log debug;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" "$upstream_addr"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
upstream platformup {
server 127.0.0.1:8081 weight=10 max_fails=2 fail_timeout=10s;
server 127.0.0.1:8082 weight=10 max_fails=2 fail_timeout=10s;
server 127.0.0.1:8083 weight=10 max_fails=2 fail_timeout=10s;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
client_max_body_size 10m;
server_name _;
root /usr/share/nginx/html;
location ~ ^/(admin|doc)/ {
proxy_pass http://platformup;
proxy_http_version 1.1;
client_max_body_size 50m;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
#proxy_next_upstream error timeout;
}
location /{
root /home/admin/project/platfrom-htdocs;
}
}
}
服务器127.0.0.1:8082已关闭。
接下来是日志:
192.168.1.2 - - [15/Aug/2019:07:18:20 -0400] "GET /admin/login.html HTTP/1.1" 499 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8083"
192.168.1.2 - - [15/Aug/2019:07:18:20 -0400] "GET /admin/login.html HTTP/1.1" 499 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8083"
192.168.1.2 - - [15/Aug/2019:07:18:21 -0400] "GET /admin/login.html HTTP/1.1" 200 6107 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8081"
192.168.1.2 - - [15/Aug/2019:07:18:21 -0400] "GET /admin/login.html HTTP/1.1" 200 6107 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8083"
192.168.1.2 - - [15/Aug/2019:07:18:21 -0400] "GET /admin/login.html HTTP/1.1" 499 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8083"
192.168.1.2 - - [15/Aug/2019:07:18:22 -0400] "GET /admin/login.html HTTP/1.1" 499 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8081"
192.168.1.2 - - [15/Aug/2019:07:18:22 -0400] "GET /admin/login.html HTTP/1.1" 200 6107 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8082, 127.0.0.1:8083"
192.168.1.2 - - [15/Aug/2019:07:18:22 -0400] "GET /admin/login.html HTTP/1.1" 499 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8081"
192.168.1.2 - - [15/Aug/2019:07:18:23 -0400] "GET /admin/login.html HTTP/1.1" 200 6107 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8081"
192.168.1.2 - - [15/Aug/2019:07:18:23 -0400] "GET /admin/login.html HTTP/1.1" 200 6107 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8083"
192.168.1.2 - - [15/Aug/2019:07:18:23 -0400] "GET /admin/login.html HTTP/1.1" 200 6107 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8083"
192.168.1.2 - - [15/Aug/2019:07:18:24 -0400] "GET /admin/login.html HTTP/1.1" 499 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8081"
192.168.1.2 - - [15/Aug/2019:07:18:24 -0400] "GET /admin/login.html HTTP/1.1" 200 6107 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8081"
192.168.1.2 - - [15/Aug/2019:07:18:25 -0400] "GET /admin/login.html HTTP/1.1" 499 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8083"
192.168.1.2 - - [15/Aug/2019:07:18:25 -0400] "GET /admin/login.html HTTP/1.1" 499 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8082, 127.0.0.1:8083"
192.168.1.2 - - [15/Aug/2019:07:18:25 -0400] "GET /admin/login.html HTTP/1.1" 200 6107 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8081"
192.168.1.2 - - [15/Aug/2019:07:18:25 -0400] "GET /admin/login.html HTTP/1.1" 200 6107 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8081"
192.168.1.2 - - [15/Aug/2019:07:18:26 -0400] "GET /admin/login.html HTTP/1.1" 200 6107 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8082, 127.0.0.1:8083"
192.168.1.2 - - [15/Aug/2019:07:18:26 -0400] "GET /admin/login.html HTTP/1.1" 499 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8081"
192.168.1.2 - - [15/Aug/2019:07:18:27 -0400] "GET /admin/login.html HTTP/1.1" 200 6107 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8083"
192.168.1.2 - - [15/Aug/2019:07:18:27 -0400] "GET /admin/login.html HTTP/1.1" 499 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8081"
192.168.1.2 - - [15/Aug/2019:07:18:27 -0400] "GET /admin/login.html HTTP/1.1" 499 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8081"
192.168.1.2 - - [15/Aug/2019:07:18:28 -0400] "GET /admin/login.html HTTP/1.1" 499 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8081"
192.168.1.2 - - [15/Aug/2019:07:18:28 -0400] "GET /admin/login.html HTTP/1.1" 499 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8081"
192.168.1.2 - - [15/Aug/2019:07:18:28 -0400] "GET /admin/login.html HTTP/1.1" 499 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8083"
192.168.1.2 - - [15/Aug/2019:07:18:28 -0400] "GET /admin/login.html HTTP/1.1" 499 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8083"
192.168.1.2 - - [15/Aug/2019:07:18:29 -0400] "GET /admin/login.html HTTP/1.1" 200 6107 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8081"
192.168.1.2 - - [15/Aug/2019:07:18:29 -0400] "GET /admin/login.html HTTP/1.1" 499 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8083"
192.168.1.2 - - [15/Aug/2019:07:18:29 -0400] "GET /admin/login.html HTTP/1.1" 499 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8083"
192.168.1.2 - - [15/Aug/2019:07:18:30 -0400] "GET /admin/login.html HTTP/1.1" 499 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8082, 127.0.0.1:8083"
192.168.1.2 - - [15/Aug/2019:07:18:30 -0400] "GET /admin/login.html HTTP/1.1" 499 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36" "-" "127.0.0.1:8081"
在15 / Aug / 2019:07:18:22和15 / Aug / 2019:07:18:26(仅4秒)之间,有三个指向节点127.0.0.1:8082的请求,但我将其配置为大多数2会在10秒内失败,那么谁能抱怨呢?请帮帮我。