Get the most out of your Centmin Mod LEMP stack
Become a Member

Wordpress Woocommerce cart remove items button (x) ajax and NGINX

Discussion in 'Blogs & CMS usage' started by jimbojimbo, Feb 22, 2018.

  1. jimbojimbo

    jimbojimbo New Member

    12
    3
    3
    Nov 9, 2017
    Ratings:
    +3
    Local Time:
    1:56 AM
    Hi,

    Im not NGINX pro by a long way but I am running a standard centminmod setup with wordpress.

    I have spotted that I cannot get the (x) remove in the cart of Woocommerce to fire. It uses AJAX with https://domain.com/cart/?remove_item=b6a1085a27ab7bff7550f8a3bd017df8&_wpnonce=XYZ

    Debugging usual methods of WP - back to default, remove all plugins except woocommerce still results in the problem.

    Im beginning to think its an NGINX issue and wondered if anyone else had any experience in issues with the AJAX requests and woocommerce? If so do you have any pointers?

    Greatly appreciated.

    Many thanks.
     
  2. eva2000

    eva2000 Administrator Staff Member

    36,039
    7,906
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,188
    Local Time:
    10:56 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    More info might be helpful
    1. What version of Centmin Mod ? 123.08stable or 123.09beta01 ? If 123.09beta01 when was it initially installed and when was last time you updated ?
    2. How was wordpress installed via centmin.sh menu option 22 wordpress installer ? Is so which caching method used wp super cache, redis nginx level cache, keycdn cache enabler ?
    3. Any reverse proxy in front i.e. sucuri, incapsula or cloudflare doing caching ?
    When you create a new nginx vhost domain via centmin.sh menu option 2 or menu option 22 or via /usr/bin/nv cli command line, you will create the Nginx vhost files and directories. You will get an outputted the path location where it will create the domain name's vhost conf file named newdomain.com.conf (and newdomain.com.ssl.conf if you selected yes to self signed SSL)
    • Nginx vhost conf path will be at /usr/local/nginx/conf/conf.d/newdomain.com.conf
    • Nginx HTTP/2 SSL vhost conf path will be at /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf
    • Nginx Self-Signed SSL Certificate Directory at /usr/local/nginx/conf/ssl/newdomain.com
    • Vhost public web root will be at /home/nginx/domains/newdomain.com/public
    • Vhost log directory will be at /home/nginx/domains/newdomain.com/log
    Please post the contents of /usr/local/nginx/conf/conf.d/newdomain.com.conf and if applicable /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf wrapped in CODE tags (outlined at How to use forum BBCODE code tags)

    what is output of these commands in ssh
    Code (Text):
    curl -I https://domain.com
    

    Code (Text):
    curl -I https://www.domain.com
    

    Code (Text):
    curl -I http://domain.com
    

    Code (Text):
    curl -I http://www.domain.com
    

    wrap output in CODE tags
     
  3. jimbojimbo

    jimbojimbo New Member

    12
    3
    3
    Nov 9, 2017
    Ratings:
    +3
    Local Time:
    1:56 AM
    Thanks for the quick reply I will reply with more detail but here is a bit more background.

    1. What version of Centmin Mod ? 123.08stable or 123.09beta01 ? If 123.09beta01 when was it initially installed and when was last time you updated ?

      123.09beta01 - Centmin was originally installed about 6 months ago. I believe it was updated recently. Bit more info. I had strangely a similar issue on an old nginx setup (not centmin) that I did 2 years ago and hit a problem where an AJAX request on the cart to proceed to payment was failing to do with an issue with SOAP. I tried updating it and still would not work. My staging running on another server with centmin was working so I migrated. I created a new site with option 22 without SSL. Once setup I reactivated the SSL using the helper output on this site and its output. I manually transferred DB and assets to build the site into the new environment. All is working well the bug then went away. Upon further inspection I have found this error. Ive had to pull the staging but my local using VVV2 (varying vagrant vagrants) is running perfectly with the desired behaviour.

    2. How was wordpress installed via centmin.sh menu option 22 wordpress installer ? Is so which caching method used wp super cache, redis nginx level cache, keycdn cache enabler ?

      Option 22. Caching ive disabled. WP total cache I deleted to eliminate it. Ive enabled and disabled Cache Enabler to see if it helps flush anything.

    3. Any reverse proxy in front i.e. sucuri, incapsula or cloudflare doing caching ?

      No its clean.
    Greatly appreciate the pointers you have provided I will work through these. They will help me immensely.
     
  4. jimbojimbo

    jimbojimbo New Member

    12
    3
    3
    Nov 9, 2017
    Ratings:
    +3
    Local Time:
    1:56 AM
    Code:
    # Centmin Mod Getting Started Guide
    # must read http://centminmod.com/getstarted.html
    # For HTTP/2 SSL Setup
    # read http://centminmod.com/nginx_configure_https_ssl_spdy.html
    
    # redirect from www to non-www  forced SSL
    # uncomment, save file and restart Nginx to enable
    # if unsure use return 302 before using return 301
    # server {
    #   server_name domain.com www.domain.com;
    #    return 302 https://domain.com$request_uri;
    # }
    
    server {
      listen 443 ssl http2;
      server_name domain.com www.domain.com;
    
      ssl_dhparam /usr/local/nginx/conf/ssl/domain.com/dhparam.pem;
      ssl_certificate      /usr/local/nginx/conf/ssl/domain.com/domain.com-acme.cer;
      ssl_certificate_key  /usr/local/nginx/conf/ssl/domain.com/domain.com-acme.key;
      include /usr/local/nginx/conf/ssl_include.conf;
    
      http2_max_field_size 16k;
      http2_max_header_size 32k;
      # dual cert supported ssl ciphers
      ssl_ciphers     EECDH+CHACHA20-draft:EECDH+CHACHA20:EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA256:EECDH+ECDSA+SHA384:EECDH+aRSA+SHA256:EECDH+aRSA+SHA384:EECDH+AES128:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA:!CAMELLIA;
      ssl_prefer_server_ciphers   on;
      #add_header Alternate-Protocol  443:npn-spdy/3;
      #add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
      #add_header X-Frame-Options SAMEORIGIN;
      #add_header X-Xss-Protection "1; mode=block" always;
      #add_header X-Content-Type-Options "nosniff" always;
      #spdy_headers_comp 5;
      ssl_buffer_size 1369;
      ssl_session_tickets on;
     
      # enable ocsp stapling
      resolver 8.8.8.8 8.8.4.4 valid=10m;
      resolver_timeout 10s;
      ssl_stapling on;
      ssl_stapling_verify on;
      ssl_trusted_certificate /usr/local/nginx/conf/ssl/domain.com/domain.com-acme.cer;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/domain.com/log/access.log combined buffer=256k flush=5m;
      error_log /home/nginx/domains/domain.com/log/error.log;
    
      root /home/nginx/domains/domain.com/public;
    
      location / {
        # Wordpress Permalinks
        try_files $uri $uri/ /index.php?q=$request_uri;
    
        include /usr/local/nginx/conf/wpsecure.conf;
        include /usr/local/nginx/conf/wpnocache.conf;
      }
    
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/php.conf;
      #include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
      include /usr/local/nginx/conf/vts_server.conf;
    }
    
    
    Code:
    # Centmin Mod Getting Started Guide
    # must read http://centminmod.com/getstarted.html
    
    # redirect from non-www to www
    # uncomment, save file and restart Nginx to enable
    # if unsure use return 302 before using return 301
    #server {
    #            listen   80;
    #            server_name domain.com;
    #            return 301 $scheme://www.domain.com$request_uri;
    #       }
    
    server {
     
      server_name domain.com www.domain.com;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
      #add_header X-Frame-Options SAMEORIGIN;
      #add_header X-Xss-Protection "1; mode=block" always;
      #add_header X-Content-Type-Options "nosniff" always;
      #add_header Referrer-Policy "strict-origin-when-cross-origin";
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/domain.com/log/access.log combined buffer=256k flush=5m;
      error_log /home/nginx/domains/domain.com/log/error.log;
    
      include /usr/local/nginx/conf/autoprotect/domain.com/autoprotect-domain.com.conf;
      root /home/nginx/domains/domain.com/public;
      # uncomment cloudflare.conf include if using cloudflare for
      # server and/or vhost site
      #include /usr/local/nginx/conf/cloudflare.conf;
      include /usr/local/nginx/conf/503include-main.conf;
    
      include /usr/local/nginx/conf/wpincludes/domain.com/wpcacheenabler_domain.com.conf;
      #include /usr/local/nginx/conf/wpincludes/domain.com/wpsupercache_domain.com.conf;
      # https://community.centminmod.com/posts/18828/
      #include /usr/local/nginx/conf/wpincludes/domain.com/rediscache_domain.com.conf;
    
      location / {
      include /usr/local/nginx/conf/503include-only.conf;
     
    
      # Enables directory listings when index file not found
      #autoindex  on;
    
      # for wordpress super cache plugin
      #try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?q=$uri&$args;
    
      # for wp cache enabler plugin
      try_files $cache_enabler_uri $uri $uri/ $custom_subdir/index.php?$args;  
    
      # Wordpress Permalinks
      #try_files $uri $uri/ /index.php?q=$uri&$args;
    
      # Nginx level redis Wordpress
      # https://community.centminmod.com/posts/18828/
      #try_files $uri $uri/ /index.php?$args;
    
      }
    
    location ~* /(wp-login\.php) {
        limit_req zone=xwplogin burst=1 nodelay;
        #limit_conn xwpconlimit 30;
    #    auth_basic "Private";
    #    auth_basic_user_file /home/nginx/domains/domain.com/htpasswd_wplogin;
        include /usr/local/nginx/conf/php-wpsc.conf;
      
        # https://community.centminmod.com/posts/18828/
        #include /usr/local/nginx/conf/php-rediscache.conf;
    }
    
    location ~* /(xmlrpc\.php) {
        limit_req zone=xwprpc burst=45 nodelay;
        #limit_conn xwpconlimit 30;
        include /usr/local/nginx/conf/php-wpsc.conf;
      
        # https://community.centminmod.com/posts/18828/
        #include /usr/local/nginx/conf/php-rediscache.conf;
    }
    
    location ~* /wp-admin/(load-scripts\.php) {
        limit_req zone=xwprpc burst=5 nodelay;
        #limit_conn xwpconlimit 30;
        include /usr/local/nginx/conf/php-wpsc.conf;
      
        # https://community.centminmod.com/posts/18828/
        #include /usr/local/nginx/conf/php-rediscache.conf;
    }
    
    location ~* /wp-admin/(load-styles\.php) {
        limit_req zone=xwprpc burst=5 nodelay;
        #limit_conn xwpconlimit 30;
        include /usr/local/nginx/conf/php-wpsc.conf;
      
        # https://community.centminmod.com/posts/18828/
        #include /usr/local/nginx/conf/php-rediscache.conf;
    }
    
      include /usr/local/nginx/conf/wpincludes/domain.com/wpsecure_domain.com.conf;
      include /usr/local/nginx/conf/php-wpsc.conf;
     
      # https://community.centminmod.com/posts/18828/
      #include /usr/local/nginx/conf/php-rediscache.conf;
     
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
      include /usr/local/nginx/conf/vts_server.conf;
    }
    
    
    Code:
    curl -I https://domain.com
    HTTP/1.1 200 OK
    Date: Wed, 21 Feb 2018 23:05:00 GMT
    Content-Type: text/html; charset=UTF-8
    Connection: keep-alive
    Vary: Accept-Encoding
    X-Pingback: https://domain.com/xmlrpc.php
    Link: <https://domain.com/wp-json/>; rel="https://api.w.org/"
    Link: <https://domain.com/>; rel=shortlink
    Server: nginx centminmod
    X-Powered-By: centminmod
    
     
  5. jimbojimbo

    jimbojimbo New Member

    12
    3
    3
    Nov 9, 2017
    Ratings:
    +3
    Local Time:
    1:56 AM
    Looking at that is it possibly a case of the wordpress related blocks need copying now to the ssl conf?

    Many many thanks by the way.
     
  6. eva2000

    eva2000 Administrator Staff Member

    36,039
    7,906
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,188
    Local Time:
    10:56 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    how did you specifically step by step disable caching specially as centmin.sh menu option 22 when installs wordpress has specific rules for excluding woocommerce cart from caching so if you removed those rules too then could be part of the problem

    has it ever worked for cart removal since centmin.sh initial install ? with keycdn cache enabler has it ever worked ?

    If it has and looks like non-https domain.com.conf vhost has your original centmin.sh menu option 22 setup config for keycdn cacher enabler, i'd reinstate those rules over to https domain.com.ssl.conf so you get the proper exclusions too i.e. would be located in include file at /usr/local/nginx/conf/wpincludes/domain.com/wpcacheenabler_domain.com.conf
     
    • Like Like x 1
  7. eva2000

    eva2000 Administrator Staff Member

    36,039
    7,906
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,188
    Local Time:
    10:56 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    • Like Like x 1
  8. jimbojimbo

    jimbojimbo New Member

    12
    3
    3
    Nov 9, 2017
    Ratings:
    +3
    Local Time:
    1:56 AM
    Thanks for getting back to me.

    Caching was just simply turning off the plugins and in total cache i had the plugin itself just deleted. I did not manually go in removing bit and pieces so that should be OK.

    I realised that the 301's for www to non-www were not working. That started giving clues that I had done something wrong somewhere.

    Ive gone back to that guide and reworked through it and its now working perfectly.

    Thank you so much for your help. Your pointers helped me immensely. Absolute star!
     
    • Like Like x 1
  9. eva2000

    eva2000 Administrator Staff Member

    36,039
    7,906
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,188
    Local Time:
    10:56 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    Sweet glad to hear you got it sorted out. Always feels good to overcome an issue and get to the other side :)
     
    • Winner Winner x 1
..