• 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 15 replies - 1 through 15 (of 19 total)
  • Plugin Author petermolnar

    (@cadeyrn)

    You have loop. When the query fails reading the entry from memcached, you fall to nocache, where you never redirect to index.php

    Since you’re not doing that, you fail on the security.limit_extensions = .php .html in the FPM config.

    Thread Starter thinstallsoft

    (@thinstallsoft)

    petermolnar, thanks very much for your kindly reply.

    However, The nginx.conf is generated by the your wp-ffpc plugin itself.

    How to redirect to index.php when it is “nocache”?

    I add try_files $uri $uri/ /index.php;

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

    The problems is also here. How to fix it? Thanks.

    Plugin Author petermolnar

    (@cadeyrn)

    I need a little time to solve this, at the moment, it beats me.

    But I’m going to remove the nginx.conf generation and just point a reference to it as an example. I was never meant to be a copy-paste thing.

    Plugin Author petermolnar

    (@cadeyrn)

    Right, I think I’ve figured it out.

    Please use this a guideline:
    https://github.com/petermolnar/wp-ffpc/blob/master/wp-ffpc-nginx-sample.conf

    I’ll release it in 1.10.1 later.

    Thread Starter thinstallsoft

    (@thinstallsoft)

    petermolnar, thanks for your work. I’ll try again and get many errors.

    nginx: [emerg] pcre_compile() failed: unrecognized character after (? or (?- in “^(?.+?\.php)(?.*)$” at “.+?\.php)(?.*)$”
    nginx: [emerg] unknown “script_name” variable
    nginx: [emerg] unknown “path_info” variable
    nginx: [emerg] “fastcgi_busy_buffers_size” must be equal to or greater than the maximum of the value of “fastcgi_buffer_size” and one of the “fastcgi_buffers”

    And finally I try to fix these erros, when I visit my website, the page shows:

    No input file specified.

    And the nginx error log shows:

    2015/10/31 11:22:04 [error] 21785#0: *6 FastCGI sent in stderr: “PHP message: PHP Warning: Unknown: failed to open stream: Success in Unknown on line 0
    Unable to open primary script: /home/wwwroot/xxx (Success)” while reading response header from upstream, client: 106.187.51.224, server: https://www.xxx.com, request: “GET / HTTP/1.1”, upstream: “fastcgi://unix:/tmp/php5-fpm.sock:”, host: “www.xxx.com”
    2015/10/31 11:23:00 [error] 21785#0: *10 FastCGI sent in stderr: “PHP message: PHP Warning: Unknown: failed to open stream: Success in Unknown on line 0
    Unable to open primary script: /home/wwwroot/xxx (Success)” while reading response header from upstream, client: 123.119.106.238, server: https://www.xxx.com, request: “POST /wp-admin/admin-ajax.php HTTP/1.1”, upstream: “fastcgi://unix:/tmp/php5-fpm.sock:”, host: “www.xxx.com”, referrer: “https://www.xxx.com/wp-admin/options-general.php?page=wp-ffpc-settings”
    2015/10/31 11:23:02 [error] 21785#0: *10 FastCGI sent in stderr: “PHP message: PHP Warning: Unknown: failed to open stream: Success in Unknown on line 0
    Unable to open primary script: /home/wwwroot/xxx (Success)” while reading response header from upstream, client: 123.119.106.238, server: https://www.xxx.com, request: “POST /wp-admin/options-general.php?page=wp-ffpc-settings HTTP/1.1”, upstream: “fastcgi://unix:/tmp/php5-fpm.sock:”, host: “www.xxx.com”, referrer: “https://www.xxx.com/wp-admin/options-general.php?page=wp-ffpc-settings”
    2015/10/31 11:23:03 [error] 21785#0: *10 FastCGI sent in stderr: “PHP message: PHP Warning: Unknown: failed to open stream: Success in Unknown on line 0
    Unable to open primary script: /home/wwwroot/xxx (Success)” while reading response header from upstream, client: 123.119.106.238, server: https://www.xxx.com, request: “GET /wp-admin/options-general.php?page=wp-ffpc-settings HTTP/1.1”, upstream: “fastcgi://unix:/tmp/php5-fpm.sock:”, host: “www.xxx.com”, referrer: “https://www.xxx.com/wp-admin/options-general.php?page=wp-ffpc-settings”

    The ngin conf is too difficult for my to config. I intend to give up the nginx memcached solution.

    Plugin Author petermolnar

    (@cadeyrn)

    nginx: [emerg] pcre_compile() failed: unrecognized character after (? or (?- in "^(?.+?\.php)(?.*)$" at ".+?\.php)(?.*)$"

    You’ve mistyped something, this is not present in the file I’ve linked.
    Check the raw version:
    https://raw.githubusercontent.com/petermolnar/wp-ffpc/master/wp-ffpc-nginx-sample.conf

    Thread Starter thinstallsoft

    (@thinstallsoft)

    I download the raw conf and upload it to the plugin directory to replace the old one.

    Then I find the new generated nginx conf in the plugin setting page and apply it to Nginx, restart nginx and get the error:

    nginx: [emerg] pcre_compile() failed: unrecognized character after (? or (?- in “^(?.+?\.php)(?.*)$” at “.+?\.php)(?.*)$”

    Thread Starter thinstallsoft

    (@thinstallsoft)

    location ~ ^(?<script_name>.+?\.php)(?<path_info>.*)$

    is translated to:

    location ~ ^(?.+?\.php)(?.*)$ {

    and fastcgi_split_path_info ^(?<script_name>.+?\.php)(?<path_info>.*)$; is translated to:

    fastcgi_split_path_info ^(?.+?\.php)(?.*)$;

    etc.

    Plugin Author petermolnar

    (@cadeyrn)

    I’m clueless.

    fastcgi_split_path_info ^(?<script_name>.+?\.php)(?<path_info>.*)$;
    and
    location ~ ^(?<script_name>.+?\.php)(?<path_info>.*)$ {

    are both from my live, nginx 1.9.5 setup of my website, working as expected.

    I don’t know what happens in your setup.

    Thread Starter thinstallsoft

    (@thinstallsoft)

    Could you send me a copy of your nginx.conf file to me?

    Thank you I too fixed my web ( https://www.dizihaberleri.biz/ )

    Plugin Author petermolnar

    (@cadeyrn)

    @thinstallsoft:
    https://pastebin.com/VQDzA78K

    This is not my entire nginx config, that is a bit too long and complex; this is all relevant to WordPress.

    Thread Starter thinstallsoft

    (@thinstallsoft)

    @petermolnar, thanks very much. I follow your conf carefully and finally make my nginx works.

    An extra question is: How to check whether the cache is loaded by Nginx from the Memcached server?

    Thread Starter thinstallsoft

    (@thinstallsoft)

    Is it beneficial or necessary to apply an object-cache.php for WordPress with WP-FFPC installed? Such as:

    Memcached Object Cache
    https://www.ads-software.com/plugins/memcached/

    MemcacheD Is Your Friend
    https://www.ads-software.com/plugins/memcached-is-your-friend/

    Plugin Author petermolnar

    (@cadeyrn)

    I’ve used object cache for a long time, but dropped it about a year ago, when it started to get too sticky, making my site acting weird.

    I might apply it again, but strictly for microcaching ( 1-2s at max ), but in that case I’m not sure they’d add much. That is since WordPress has wp_cache_* functions, usually not utilized in themes. It’s not a persistent cache, only for the duration of the page generation; however, it can still give a kick. Before going for an object cache, maybe try this. ( And also set MySQL to do query caches. )

    But to answer your question: if a site is served from cache with ffpc, then it will never even reach the object cache part.
    Object cache will only kick in when the page is rendered with WordPress, not from cache.

    As for the first question: add something like
    add_header X-Cache-Engine "the not you'd like to see";

    to the nginx conf, to the part you’d want to identify.

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