服务器设置

服务器设置

我遇到了 Nginx Cache 和 wordpress 的问题。

信息:Nginx 和 WP 可以正常工作,但如果我尝试使用缓存,则会出现一些问题。

当活动缓存 nginx

日志 nginx =

[alert] 19958#0: worker process 19963 exited on signal 9
[alert] 19958#0: worker process 19966 exited on signal 9
[alert] 19958#0: worker process 19961 exited on signal 9
[alert] 19958#0: worker process 19965 exited on signal 9
[alert] 19958#0: worker process 19970 exited on signal 9
[alert] 19958#0: worker process 19968 exited on signal 9
[alert] 19958#0: worker process 19962 exited on signal 9
[alert] 19958#0: worker process 19967 exited on signal 9
[alert] 19958#0: worker process 19959 exited on signal 9
[alert] 19958#0: worker process 19960 exited on signal 9
[alert] 19958#0: worker process 19969 exited on signal 9

我重新启动了 apache 和 nginx,同样的问题

我不明白我的配置哪里出了问题。

如果有人能帮助我,他会非常好

nginx.conf

user www-data;
worker_processes 12;
pid /var/run/nginx.pid;

events {
        worker_connections 1024;
}

http {
        ##
        # Basic Settings
        ##
        limit_req_zone $binary_remote_addr zone=one:10m rate=5r/s;
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 60;
        types_hash_max_size 2048;
        set_real_ip_from 127.0.0.1;
        real_ip_header X-Forwarded-For;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;
        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}

可用站点 - mywebsite.com

服务器设置

proxy_cache_path /home/mywebsite/cache/nginx levels=1:2 keys_zone=staticfilecache:180m
max_size=2500m;
proxy_read_timeout 170;
proxy_send_timeout 90;
proxy_cache_key "$scheme$host$request_uri";
upstream apache {
server 127.0.0.1:8080;
}

server {
listen 80;
server_name www.mywebsite.com;
access_log  /home/mywebsite/logs/access.log;
error_log   /home/mywebsite/logs/error.log;
add_header X-Cache-Status $upstream_cache_status;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "";
proxy_cache_valid 200 20m;
client_max_body_size       2090m;
proxy_connect_timeout      90;
proxy_buffer_size          2024k;
proxy_buffers               8 512k;
proxy_buffering                 on;
proxy_busy_buffers_size     2024k;
proxy_temp_file_write_size 2024k;
proxy_ignore_client_abort on;
proxy_http_version 1.1;

location / {
limit_req   zone=one burst=8 nodelay;
limit_rate 5000k;

# If logged in, don't cache.
if ($http_cookie ~* "comment_author_|wordpress_(?!test_cookie)|wp-postpass_" ) {
set $do_not_cache 1;
}
proxy_no_cache $do_not_cache;
proxy_cache_bypass $do_not_cache;
proxy_cache staticfilecache;
proxy_pass http://apache;
proxy_cache_valid 200 20m;
}

location ~* wp-.*.php|wp-admin {
proxy_pass http://apache;
}
location ~* .(jpg|png|gif|jpeg|css|js|mp3|wav|swf|mov|doc|pdf|xls|ppt|docx|pptx|xlsx|ico)$ {
proxy_cache staticfilecache;
proxy_pass http://apache;
proxy_cache_valid 200 120m;
expires 15552000;
}
location ~* /[^/]+/(feed|.xml)/? {
if ($http_cookie ~* "comment_author_|wordpress_(?!test_cookie)|wp-postpass_" ) {
set $do_not_cache 1;
}
proxy_no_cache $do_not_cache;
proxy_cache_bypass $do_not_cache;
proxy_cache staticfilecache;
proxy_pass http://apache;
proxy_cache_valid 200 45m;
expires 3600;
}
location = /50x.html {
root /var/www/nginx-default;
}
# No access to .htaccess files.
location ~ /.ht {
deny all;
}
}
## Listen banned IP addresses via blockips.conf   ##
 include blockips.conf;

相关内容