Nginx 经常不处理请求

fanstast 2016-08-23 04:35:06
症状:最近网站经常突然出现长时间等待服务器响应,等待时间长达几分钟。莫名其妙的症状,已经把服务器重装重新配置环境还是有问题,着实摸不着头脑。麻烦大佬看看nginx配置哪里出了问题,分全在这了。

memcached MAXCONN=5000

一般一天需要处理 30W PV

出现问题时
本地链接数
527 127.0.0.1


正常时
2000 127.0.0.1


详细站点nginx配置:


fastcgi_cache_path /tmp/wpcache levels=1:2 keys_zone=WORDPRESS:512m inactive=1d max_size=10G;
fastcgi_cache_path /tmp/nologin levels=1:2 keys_zone=nologin:512m inactive=1d max_size=10G;
fastcgi_temp_path /tmp/temp;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500;
#忽略一切nocache申明,避免不缓存伪静态等
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
server {
listen 8.8.8.8:443 ssl reuseport;
server_name domain name;
ssl on;
ssl_certificate /root/letssl/domain.crt;
ssl_certificate_key /root/letssl/domain.key;
ssl_dhparam /root/letssl/dhparam.pem;
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
#ssl_ciphers EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH;
ssl_session_cache shared:SSL:50m;
ssl_session_timeout 1d;
ssl_session_tickets on;
ssl_session_ticket_key /root/letssl/session_ticket.key;
ssl_stapling on;
ssl_stapling_verify on;
ssl_trusted_certificate /root/letssl/domain.crt;
resolver 8.8.8.8 valid=300s;
resolver_timeout 10s;
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";

root /data/wwwroot/domain;
access_log /data/wwwlogs/domain_nginx.log combined;
index index.html index.htm index.jsp index.php;

include /usr/local/nginx/conf/rewrite/pagespeed.conf;

if ($host = 'www.domain' ) {
rewrite ^/(.*)$ https://domain/$1 permanent;
}

location ^~ /xmlrpc.php {
deny all;
}

location /.well-known/acme-challenge/ {
alias /tmp/challenges/.well-known/acme-challenge/;
try_files $uri =404;
}

location / {
try_files $uri $uri/ /index.php?$args;
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;

if ( $query_string ~* ".*[\;'\<\>].*" ){
return 404;
}

location ~* \.(ini|gz|zip|tar)$ {
deny all;
}

set $login_cache 1;
set $nlogin_cache 0;
if ($http_cookie ~* "wordpress_logged_in") {
set $login_cache "${login_cache}0";
set $nlogin_cache 1;
}
if ($request_uri ~* "/[0-9]+.html|/category/|/musiclive") {
set $login_cache "${login_cache}2";
}
if ($request_method = POST) {
set $h_cache 1;
}
if ($query_string != "") {
set $h_cache 1;
}
if ($request_uri ~* "/wp-admin/|/user/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
set $h_cache 1;
}
if ($request_uri ~ "/go") {
set $h_cache 0;
}
if ($http_cookie ~* "fuck") {
set $h_cache 1;
set $h_cache 1;
}
if ( $nlogin_cache = "0" ){
set $login_cache 0;
set $cachedr "nologin";
}
if ( $login_cache = "102" ){
set $wp_cache 0;
set $cachedr "WORDPRESS";
}
if ( $h_cache = "0" ){
set $wp_cache 0;
}
if ( $h_cache = "1" ){
set $wp_cache 1;
}

location ~ [^/]\.php(/|$) {
#fastcgi_pass remote_php_ip:9000;
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
#缓存
fastcgi_cache_bypass $wp_cache;
fastcgi_no_cache $wp_cache;
add_header X-Cache "$upstream_cache_status";
fastcgi_cache $cachedr;
fastcgi_cache_valid 200 1d;
fastcgi_cache_valid 301 302 404 1h;
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico|ttf|woff)$ {
expires 360d;
access_log off;
}

location ~ .*\.(js|css)?$ {
expires 30d;
access_log off;
}
}
...全文
898 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
yeksama 2016-08-26
  • 打赏
  • 举报
回复
php问题哦,你看看php

25,980

社区成员

发帖
与我相关
我的任务
社区描述
高性能WEB开发
社区管理员
  • 高性能WEB开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧