Want more timely Centmin Mod News Updates?
Become a Member

404 error on mobile devices - autoprotect.sh?

Discussion in 'Install & Upgrades or Pre-Install Questions' started by dgd132, Sep 18, 2018.

  1. dgd132

    dgd132 New Member

    12
    4
    3
    Sep 12, 2018
    Ratings:
    +4
    Local Time:
    6:32 PM
    i have a civicrm and wordpress install using centiminmod.

    all up and running fine , initially but I am now getting 404 errors when accessing pages on mobile devices which i was not getting a few days ago.

    the only changes I can I have made to the serveer set up is running autoprotect.sh to replicate htaccess.

    so two questions:
    1. could this cause device dependent 404 errors?
    2. is there an easy way to rollback / disable the autoprotect.sh to test the theory?
     
    Last edited: Sep 18, 2018
  2. eva2000

    eva2000 Administrator Staff Member

    36,387
    7,992
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,304
    Local Time:
    3:32 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    If you want to manually bypass the directory from auto protection via a .autoprotect-bypass file - details below here.

    You can read a few threads below on how autoprotect.sh may have caught some folks web apps falsely and the workarounds or improvements made to autoprotect.sh with the help of users feedback and troubleshooting.
    Check if your nginx vhost at either or both /usr/local/nginx/conf/conf.d/domain.com.conf and/or /usr/local/nginx/conf/conf.d/domain.com.ssl.conf has include file for autoprotect example
    Code (Text):
    include /usr/local/nginx/conf/autoprotect/domain.com/autoprotect-domain.com.conf;
    

    see if your directory for the script which has issues is caught in an autoprotect include entry in /usr/local/nginx/conf/autoprotect/domain.com/autoprotect-domain.com.conf which has a deny all entry
    Code (Text):
    cat /usr/local/nginx/conf/autoprotect/domain.com/autoprotect-domain.com.conf
    

    i.e.
    Code (Text):
    # /home/nginx/domains/domain.com/public/subdirectory/js
    location ~* ^/subdirectory/js/ { allow 127.0.0.1; deny all; }
    

    If caught you can whitelist it by autoprotect bypass .autoprotect-bypass file - details below here. So if problem js file is at domain.com/subdirectory/js/file.js then it is likely /subdirectory/js has a .htaccess with deny all in it - make sure that directory is meant to be publicly accessible by contacting author of script and if so, you can whitelist it and re-run autoprotect script to regenerate your /usr/local/nginx/conf/autoprotect/domain.com/autoprotect-domain.com.conf include file
    Code (Text):
    cd /home/nginx/domains/domain.com/public/subdirectory/js
    touch .autoprotect-bypass
    /usr/local/src/centminmod/tools/autoprotect.sh
    nprestart
    

    it maybe you need to also whitelist /subdirectory then it would be as follows creating bypass files at /home/nginx/domains/domain.com/public/subdirectory/.autoprotect-bypass and /home/nginx/domains/domain.com/public/subdirectory/js/.autoprotect-bypass
    Code (Text):
    cd /home/nginx/domains/domain.com/public/subdirectory/
    touch .autoprotect-bypass
    cd /home/nginx/domains/domain.com/public/subdirectory/js
    touch .autoprotect-bypass
    /usr/local/src/centminmod/tools/autoprotect.sh
    nprestart
    

    then double check to see if updated /usr/local/nginx/conf/autoprotect/domain.com/autoprotect-domain.com.conf include file now doesn't show an entry for /subdirectory/js
     
  3. dgd132

    dgd132 New Member

    12
    4
    3
    Sep 12, 2018
    Ratings:
    +4
    Local Time:
    6:32 PM
    thanks Eva - I've restored a server backup which has alleviated the 404 errors.

    i've only got four .htaccess protected directories so I've manually added them to the domains conf file. all seems to be working OK again now on all devices.
     
    • Like Like x 1
  4. eva2000

    eva2000 Administrator Staff Member

    36,387
    7,992
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,304
    Local Time:
    3:32 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    Glad to hear :)
     
..