• Resolved thinstallsoft

    (@thinstallsoft)


    Hi,

    I just install WP-FFPC and find several problems. After I apply the nginx conf, I could not visit my site.

    The website homepage is just a blank page (not login). The response header:

    HTTP/1.1 200 OK
    Server: nginx/1.9.6
    Date: Fri, 30 Oct 2015 11:31:23 GMT
    Content-Type: text/html; charset=UTF-8
    Transfer-Encoding: chunked
    Connection: keep-alive
    X-Cache-Engine: not cached

    Visit the https://www.xxx.com/wp-admin/, Get ‘Access denied’ Error:

    HTTP/1.1 403 Forbidden
    Server: nginx/1.9.6
    Date: Fri, 30 Oct 2015 11:34:10 GMT
    Content-Type: text/html; charset=UTF-8
    Transfer-Encoding: chunked
    Connection: keep-alive

    The whole nginx.conf:

    user www www;
    worker_processes 16;

    worker_cpu_affinity 0000000000000001 0000000000000010 0000000000000100 0000000000001000 0000000000010000 0000000000100000 0000000001000000 0000000010000000 0000000100000000 0000001000000000 0000010000000000 0000100000000000 0001000000000000 0010000000000000 0100000000000000 1000000000000000;

    error_log /home/wwwlogs/error_nginx.log crit;
    pid /var/run/nginx.pid;
    google_perftools_profiles /tmp/tcmalloc;
    worker_rlimit_nofile 1024000;

    events {
    use epoll;
    worker_connections 1024000;
    }

    http {
    # memcached servers, generated according to wp-ffpc config
    upstream memcached-servers {
    server 127.0.0.1:11211;
    }
    # PHP-FPM upstream; change it accordingly to your local config!
    upstream php-fpm {
    server unix:/dev/shm/php-cgi.sock;
    }
    server {
    listen 80;
    index index.php
    server_name https://www.xxx.com;
    root /home/wwwroot/xxx/;

    # set up logging
    access_log /var/log/nginx/www.xxx.com.access.log;
    error_log /var/log/nginx/www.xxx.com.error.log;

    ## PHP5-FPM
    location ~ (\.php) {
    # these settings are usually in fastcgi_params

    fastcgi_index index.php;
    fastcgi_connect_timeout 10;
    fastcgi_send_timeout 180;
    fastcgi_read_timeout 180;
    fastcgi_buffer_size 512k;
    fastcgi_buffers 4 256k;
    fastcgi_busy_buffers_size 512k;
    fastcgi_temp_file_write_size 512k;
    fastcgi_intercept_errors on;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    fastcgi_keep_conn on;

    fastcgi_param QUERY_STRING $query_string;
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param CONTENT_TYPE $content_type;
    fastcgi_param CONTENT_LENGTH $content_length;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    fastcgi_param REQUEST_URI $request_uri;
    fastcgi_param DOCUMENT_URI $document_uri;
    fastcgi_param DOCUMENT_ROOT $document_root;
    fastcgi_param SERVER_PROTOCOL $server_protocol;
    fastcgi_param GATEWAY_INTERFACE CGI/1.1;
    fastcgi_param SERVER_SOFTWARE nginx;
    fastcgi_param REMOTE_ADDR $remote_addr;
    fastcgi_param REMOTE_PORT $remote_port;
    fastcgi_param SERVER_ADDR $server_addr;
    fastcgi_param SERVER_PORT $server_port;
    fastcgi_param SERVER_NAME $server_name;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
    fastcgi_param REDIRECT_STATUS 200;

    # uncomment these for HTTPS usage
    #fastcgi_param HTTPS $https if_not_empty;
    #fastcgi_param SSL_PROTOCOL $ssl_protocol if_not_empty;
    #fastcgi_param SSL_CIPHER $ssl_cipher if_not_empty;
    #fastcgi_param SSL_SESSION_ID $ssl_session_id if_not_empty;
    #fastcgi_param SSL_CLIENT_VERIFY $ssl_client_verify if_not_empty;

    default_type text/html;

    set $memcached_raw_key $scheme://$host$request_uri;

    set $memcached_key data-$memcached_raw_key;

    set $memcached_request 1;

    if ($request_method = POST ) {
    set $memcached_request 0;
    }

    if ( $uri ~ “/wp-” ) {
    set $memcached_request 0;
    }

    if ( $args ) {
    set $memcached_request 0;
    }

    if ($http_cookie ~* “comment_author_|wordpressuser_|wp-postpass_|wordpress_logged_in_” ) {
    set $memcached_request 0;
    }

    if ( $memcached_request = 1) {

    memcached_pass memcached-servers;
    error_page 404 = @nocache;
    break;
    }

    fastcgi_pass unix:/dev/shm/php-cgi.sock;
    }

    location @nocache {
    add_header X-Cache-Engine “not cached”;
    fastcgi_pass unix:/dev/shm/php-cgi.sock;
    }

    location / {
    try_files $uri $uri/ /index.php;
    }
    }
    }

    The Nginx error log:

    2015/10/30 19:25:02 [error] 14381#0: *8 FastCGI sent in stderr: “Access to the script ‘/home/wwwroot/xxx’ has been denied (see security.limit_extensions)” while reading response header from upstream, client: 123.119.106.238, server: , request: “GET / HTTP/1.1”, upstream: “fastcgi://unix:/dev/shm/php-cgi.sock:”, host: “www.xxx.com”
    2015/10/30 19:25:03 [error] 14381#0: *8 FastCGI sent in stderr: “Access to the script ‘/home/wwwroot/xxx’ has been denied (see security.limit_extensions)” while reading response header from upstream, client: 123.119.106.238, server: , request: “POST /wp-admin/admin-ajax.php HTTP/1.1”, upstream: “fastcgi://unix:/dev/shm/php-cgi.sock:”, host: “www.xxx.com”, referrer: “https://www.xxx.com/wp-admin/options-general.php?page=wp-ffpc-settings”
    2015/10/30 19:25:07 [error] 14381#0: *8 FastCGI sent in stderr: “Access to the script ‘/home/wwwroot/xxx’ has been denied (see security.limit_extensions)” while reading response header from upstream, client: 123.119.106.238, server: , request: “POST /wp-admin/admin-ajax.php HTTP/1.1”, upstream: “fastcgi://unix:/dev/shm/php-cgi.sock:”, host: “www.xxx.com”, referrer: “https://www.xxx.com/wp-admin/options-general.php?page=wp-ffpc-settings”
    2015/10/30 19:26:04 [error] 14381#0: *8 FastCGI sent in stderr: “Access to the script ‘/home/wwwroot/xxx’ has been denied (see security.limit_extensions)” while reading response header from upstream, client: 123.119.106.238, server: , request: “POST /wp-admin/admin-ajax.php HTTP/1.1”, upstream: “fastcgi://unix:/dev/shm/php-cgi.sock:”, host: “www.xxx.com”, referrer: “https://www.xxx.com/wp-admin/options-general.php?page=wp-ffpc-settings”
    2015/10/30 19:26:06 [error] 14381#0: *8 FastCGI sent in stderr: “Access to the script ‘/home/wwwroot/xxx’ has been denied (see security.limit_extensions)” while reading response header from upstream, client: 123.119.106.238, server: , request: “GET / HTTP/1.1”, upstream: “fastcgi://unix:/dev/shm/php-cgi.sock:”, host: “www.xxx.com”
    2015/10/30 19:26:08 [error] 14381#0: *8 FastCGI sent in stderr: “Access to the script ‘/home/wwwroot/xxx’ has been denied (see security.limit_extensions)” while reading response header from upstream, client: 123.119.106.238, server: , request: “POST /wp-admin/admin-ajax.php HTTP/1.1”, upstream: “fastcgi://unix:/dev/shm/php-cgi.sock:”, host: “www.xxx.com”, referrer: “https://www.xxx.com/wp-admin/options-general.php?page=wp-ffpc-settings”
    2015/10/30 19:26:11 [error] 14381#0: *8 FastCGI sent in stderr: “Access to the script ‘/home/wwwroot/xxx’ has been denied (see security.limit_extensions)” while reading response header from upstream, client: 123.119.106.238, server: , request: “GET / HTTP/1.1”, upstream: “fastcgi://unix:/dev/shm/php-cgi.sock:”, host: “www.xxx.com”
    2015/10/30 19:27:07 [error] 14381#0: *17 FastCGI sent in stderr: “Access to the script ‘/home/wwwroot/xxx’ has been denied (see security.limit_extensions)” while reading response header from upstream, client: 123.119.106.238, server: , request: “GET /wp-admin/ HTTP/1.1”, upstream: “fastcgi://unix:/dev/shm/php-cgi.sock:”, host: “www.xxx.com”
    2015/10/30 19:34:10 [error] 14381#0: *33 FastCGI sent in stderr: “Access to the script ‘/home/wwwroot/xxx’ has been denied (see security.limit_extensions)” while reading response header from upstream, client: 123.119.106.238, server: , request: “GET /wp-admin/ HTTP/1.1”, upstream: “fastcgi://unix:/dev/shm/php-cgi.sock:”, host: “www.xxx.com”

    And the php-fpm.conf:

    [global]
    pid = run/php-fpm.pid
    error_log = log/php-fpm.log
    log_level = warning

    emergency_restart_threshold = 30
    emergency_restart_interval = 60s
    process_control_timeout = 5s
    daemonize = yes

    [www]
    listen = /dev/shm/php-cgi.sock
    # listen = /var/run/php5-fpm.sock;
    listen.backlog = -1
    listen.allowed_clients = 127.0.0.1
    listen.owner = www
    listen.group = www
    listen.mode = 0666

    security.limit_extensions = .php .html

    user = www
    group = www
    pm = dynamic

    # pm.start_servers = 80
    # pm.max_children = 120
    # pm.min_spare_servers = 70
    # pm.max_spare_servers = 120

    pm.start_servers = 80
    pm.max_children = 360
    pm.min_spare_servers = 80
    pm.max_spare_servers = 360

    pm.max_requests = 10240

    pm.process_idle_timeout = 10s

    request_terminate_timeout = 300

    rlimit_files = 1024000
    rlimit_core = 0

    catch_workers_output = yes
    env[PATH] = /usr/local/bin:/usr/bin:/bin
    env[TMP] = /tmp
    env[TMPDIR] = /tmp
    env[TEMP] = /tmp

    Nginx: 1.9.6
    PHP: 5.6.14
    Memcached: 1.4.24

    Please help me out. Thanks.

    https://www.ads-software.com/plugins/wp-ffpc/

Viewing 4 replies - 16 through 19 (of 19 total)
  • Thread Starter thinstallsoft

    (@thinstallsoft)

    Thanks for your detail explanation about the object cache. I know it now.

    And for the add_header, I add three test header into my conf:

    add_header test_header “111111”;
    add_header test_header “222222”;
    add_header test_header “333333”;

    in differention locations.

    I think the ‘test_header: 222222’ would show that the cache is served by Nginx from the Memcached. Is it right?

    However, I could only see the test_header: 333333 value, I refresh the page for many times and in many environment. Is there anything wrong?

    my conf:

    server {
    listen 80;
    server_name _;
    index index.php;
    root /home/wwwroot/;

    access_log /var/log/aaa.access.log;
    error_log /var/log/aaa.error.log;

    set $memcached_raw_key $scheme://$host$request_uri;
    set $memcached_key data-$memcached_raw_key;
    set $memcached_request 0;

    if ($request_method = POST) {
    set $memcached_request 0;
    }

    if ($uri ~ “/wp-“) {
    set $memcached_request 0;
    }

    if ($args) {
    set $memcached_request 0;
    }

    if ($http_cookie ~* “comment_author_|wordpressuser_|wp-postpass_|wordpress_logged_in_”) {
    set $memcached_request 0;
    }

    location @fallback {
    add_header test_header “111111”;
    fastcgi_split_path_info ^(?<script_name>.+?\.php)(?<path_info>.*)$;
    fastcgi_param SCRIPT_FILENAME $document_root$script_name;
    fastcgi_param PATH_TRANSLATED $document_root$path_info;
    include fastcgi;
    fastcgi_keep_conn on;
    fastcgi_pass php-fpm;
    }

    location ~ ^(?<script_name>.+?\.php)(?<path_info>.*)$ {
    default_type text/html;
    if ($memcached_request = 1) {
    add_header test_header “222222”;
    memcached_pass memcached;
    error_page 404 = @fallback;
    }
    fastcgi_split_path_info ^(?<script_name>.+?\.php)(?<path_info>.*)$;
    fastcgi_param SCRIPT_FILENAME $document_root$script_name;
    fastcgi_param PATH_TRANSLATED $document_root$path_info;
    include fastcgi;
    fastcgi_keep_conn on;
    fastcgi_pass php-fpm;
    add_header test_header “333333”;
    }

    location / {
    try_files $uri $uri/ @rewrites;
    }
    location @rewrites {
    rewrite ^ /index.php last;
    }
    }

    Thread Starter thinstallsoft

    (@thinstallsoft)

    I change the

    set $memcached_request 0;

    to

    set $memcached_request 1;

    And I could see the test_header: 222222.

    So, is it confirmed that fetching cache from Memcached by Nginx is working now?

    Plugin Author petermolnar

    (@cadeyrn)

    set $memcached_request 1; is the one that should be; I’ve turned it to 0 to specifically bypass the nginx-memcached setting. sorry for leaving it on 0 and finding it.

    Yes, if you see 222222, it should be served from nginx. If you want to deeper verify it, turn on the memcached debugging ( add -vvv for starting ) and check if only the ‘data-‘ keys are served. If ‘meta-‘ is served ( GET ), it’s still served from the cache, but with PHP. If you see ‘SET’, that entry is currently being written to the cache.

    Thread Starter thinstallsoft

    (@thinstallsoft)

    petermolnar, thanks for your patient reply for all my questions. I just check the memcached log and it works like a charm. Wish you happy every day.

Viewing 4 replies - 16 through 19 (of 19 total)
  • The topic ‘'Access denied' Error on /wp-admin/ and Blank Page on other pages’ is closed to new replies.