我在Ubuntu18.08上运行了以下堆栈,并将其定义为:
mariadb:10.3.20实例wordpress:5.3.0-php7.2的自定义wordpress实例及其上安装的ioncubenginx:1.13的自定义nginx实例及其上安装的nginx-amplify-agentnginx的配置:
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 10000;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
log_format main_ext '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'"$host" sn="$server_name" '
'rt=$request_time '
'ua="$upstream_addr" us="$upstream_status" '
'ut="$upstream_response_time" ul="$upstream_response_length" '
'cs=$upstream_cache_status' ;
access_log /var/log/nginx/access.log main_ext;
error_log /var/log/nginx/error.log warn;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
gzip on;
include /etc/nginx/conf.d/*.conf;
}网站的定义如下:
server {
listen 80;
listen [::]:80;
server_name some.org www.some.org;
location / {
rewrite ^ https://$host$request_uri? permanent;
}
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name some.org www.some.org;
index index.php index.html index.htm;
root /var/www/html;
server_tokens off;
ssl_certificate /etc/letsencrypt/live/some.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/some.org/privkey.pem;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Content-Security-Policy "default-src * data: 'unsafe-eval' 'unsafe-inline'" always;
# add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
# enable strict transport security only if you understand the implications
location / {
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
proxy_redirect off;
proxy_pass http://wordpress;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
location = /favicon.ico {
log_not_found off; access_log off;
}
location = /robots.txt {
log_not_found off; access_log off; allow all;
}
location ~* \.(css|js|gif|ico|jpeg|jpg|png)$ {
expires max;
log_not_found off;
}
}整个堆栈按照预期工作,除非10-15个用户来到网站并尝试执行操作。在这种情况下,一些请求开始挂起(通常是对某个组件的POST请求),3-4分钟后,它被释放,没有任何错误,用户实际上可以看到它的结果。在挂起的网站变得不负责从同一个浏览器(但从其他人,一切都好!)一旦请求发布-网站再次负责。
日志也很奇怪:
nginx访问日志:
62.96.39.243 - - [17/Jan/2020:10:56:41 +0000] "GET /something
78.43.40.52 - - [17/Jan/2020:10:56:41 +0000] "POST /ajax-bidsform.html?meth=post&yid=d7f9f1a1a0bf HTTP/2.0" 200 208 "https://some.org/xchange_XRP_to_SBERRUB/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36" "-"
78.43.40.52 - - [17/Jan/2020:10:56:41 +0000] "GET /somethingwordpress:
134.19.130.91 - - [17/Jan/2020:10:56:40 +0000] "GET /something
78.43.40.52 - - [17/Jan/2020:10:50:07 +0000] "POST /ajax-bidsform.html?meth=post&yid=d7f9f1a1a0bf HTTP/1.0" 200 559 "https://some.org/xchange_XRP_to_SBERRUB/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36"
62.96.39.243 - - [17/Jan/2020:10:56:41 +0000] "GET /something如您所见,挂起的POST /ajax-bidsform.html...在nginx日志中的时间是10:56,在wordpress中是10:50 -而这正是客户端完成此请求的时间。据我所知,这意味着该请求在nginx级别上停留了将近6分钟,直到它实际上被传递给wordpress。如您所见,我没有nginx的ddos保护指令。
另外,我也注意到:在挂起的请求中,没有任何CPU或RAM的长期峰值,因此很可能与硬件问题无关。我还在想,它在某种程度上与挂起的脚本(即ajax-bidsform.html)有关,但只有当我们从虚拟主机迁移到数字海洋的云实例(以前从未发生过)时,它才开始发生,所以我想这是一个配置问题。日志中请求的时间线也可以证明这一点。
到目前为止,我确实试图:
worker_connections提高到10000net.core.somaxconn增加到1024但问题仍在发生..。任何想法或想法都将不胜感激!
发布于 2020-01-18 17:55:12
10:56在nginx日志中,10:50在wordpress中
我将把这理解为wordpress在10:50接收请求,并在10:56将结果返回给nginx。要确定,您可以在nginx中将upstream_response_time添加到log_format中。见利用NGINX测井技术进行应用性能监测。
https://serverfault.com/questions/999456
复制相似问题