Learn about Centmin Mod LEMP Stack today
Register Now

Nginx 404 not triggering

Discussion in 'Install & Upgrades or Pre-Install Questions' started by noly, Jul 30, 2017.

  1. noly

    noly Premium Member Premium Member

    71
    10
    8
    Jul 24, 2017
    Frankfurt/Germany
    Ratings:
    +20
    Local Time:
    4:34 AM
    1.13.x
    10.x
    • CentOS Version: CentOS 7 64bit
    • Centmin Mod Version Installed: 123.09beta01
    • Nginx Version Installed: 1.13.3
    • PHP Version Installed: 7.0.20
    • MariaDB MySQL Version Installed: 10.1.25
    • When was last time updated Centmin Mod code base : code is uptodate
    • Persistent Config:
      NGXDYNAMIC_NGXPAGESPEED='y'
      NGINX_PAGESPEED='y'
      LETSENCRYPT_DETECT=’y’
      ACMEDEBUG='y'
      PUREFTPD_DISABLED=y

    So here is the issue i am facing...


    Story behind:

    In my logs i saw that google and bings bots are trying to access files which are not exisiting.
    After research i found out that there is a site (let's call it competitor.com) pointing with bad links to my site.
    Google and Bing are following those links which results in countless errors of files not found.
    I guess that harms the ranking of the site so i created a .txt with all those links and told Google & Bing to disavow them.
    Hope that helps. -_-



    Nginx challenges:

    1.
    The 404 error page is triggered correctly when trying to access a non-exisiting file in root...

    For example..

    domain.com/_i-dont-exist.php or domain.com/_directory-not-exisiting_

    ..shows correctly the 404 page but doesn't redirect to it.



    2.
    The error page is triggered BUT the assets (domain.com/subdirectory/css & domain.com/subdirectory/js etc.) are not loaded when trying to access...

    domain.com/_directory-not-exisiting_/_i-dont-exist.php or domain.com/_directory-not-exisiting_/_directory-not-exisiting_



    3.
    The error page is NOT triggered AND the assets (domain.com/subdirectory/css & domain.com/subdirectory/js etc.) are not loaded when trying to access...

    domain.com/_i-exist.php/_i-dont-exist.php or domain.com/_i-exist.php/_directory-not-exisiting_




    I think i tried already tons of different ways of modificating "try_files $uri $uri/ /.." but unfortunately none of them worked.
    Obviously it seems to work correctly at centminmod.com ...just without the redirect. I would be fine with that too though. ;-)


    Anyone got an idea/solution or can point me to the right direction please?
     
  2. eva2000

    eva2000 Administrator Staff Member

    30,170
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,138
    Local Time:
    12:34 PM
    Nginx 1.13.x
    MariaDB 5.5
    1st and 2nd examples are as expected - there's no redirect just 404 error

    2nd example expected due to how your style references css/js files + - there's no redirect just 404 error

    3. for security php-fpm/nginx isn't configured to parse php after .php so .php/file/direct/etc won't work anyway and if you have php web app like wordpress, drupal, xenforo, .php not found is handled by those web apps not centmin mod nginx.php
     
    • Informative Informative x 1
  3. noly

    noly Premium Member Premium Member

    71
    10
    8
    Jul 24, 2017
    Frankfurt/Germany
    Ratings:
    +20
    Local Time:
    4:34 AM
    1.13.x
    10.x
    Thanks for replying. :)

    1. behaviour as expected, yes.
    2. thanks for pointing me to the right direction....sure, one can set e.g. <base href..>

    3. true..wordpress handles that right. But on that specific site i am using plain php.

    domain.com/_i-exist.php/_i-dont-exist.php

    ...shows the _i-exist.php but assets are not loaded (404) because they are at root ( /assets).

    Yes, i could <base href..>-it too...but i have a feeling that that's not the way to do it.
    Do you agree?
    Any idea how wp handles that?