Welcome to Centmin Mod Community
Register Now

Nginx Custom Error Pages setup

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by skringjer, Jun 5, 2021.

  1. skringjer

    skringjer NoobMaster69

    208
    26
    28
    Apr 21, 2019
    Ratings:
    +43
    Local Time:
    4:57 AM
    Nginx 1.21.6
    MariaDB 10.3.x
    Im trying to setup custom error page for my site, i have all the default error pages in my root folder, uncommended errorpage.conf from both nginx and domain vhost, restarted nginx and php-fpm but still it shows the default 404 for Geoip rule, though on the domain / server ip its showing the pages.


    Actually i am trying this for GEOIP

    Code:
      if ($country_code_allowed = deny) {
      return 404;
    }

    Is there something else i have to do to show custom pages for Geoip ban returns?
     
  2. skringjer

    skringjer NoobMaster69

    208
    26
    28
    Apr 21, 2019
    Ratings:
    +43
    Local Time:
    4:57 AM
    Nginx 1.21.6
    MariaDB 10.3.x
    Any help please?
     
  3. skringjer

    skringjer NoobMaster69

    208
    26
    28
    Apr 21, 2019
    Ratings:
    +43
    Local Time:
    4:57 AM
    Nginx 1.21.6
    MariaDB 10.3.x
    I also googled and tried some methods but none work, will keep digging and update this page.
     
  4. skringjer

    skringjer NoobMaster69

    208
    26
    28
    Apr 21, 2019
    Ratings:
    +43
    Local Time:
    4:57 AM
    Nginx 1.21.6
    MariaDB 10.3.x
    No solutions found, any help would be appreciated
     
  5. skringjer

    skringjer NoobMaster69

    208
    26
    28
    Apr 21, 2019
    Ratings:
    +43
    Local Time:
    4:57 AM
    Nginx 1.21.6
    MariaDB 10.3.x
    @eva2000 sorry for tagging, but any clues im still trying to fix it.
     
  6. skringjer

    skringjer NoobMaster69

    208
    26
    28
    Apr 21, 2019
    Ratings:
    +43
    Local Time:
    4:57 AM
    Nginx 1.21.6
    MariaDB 10.3.x
    Could anyone help me out please?
     
  7. eva2000

    eva2000 Administrator Staff Member

    58,893
    12,490
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,122
    Local Time:
    9:57 AM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    What web app is this? if it's PHP it might need modifying the php.conf include with your specific 404 directive.

    Centmin Mod is provide as is, so short of scripted related bugs or issues, any further optimisation to the web stack components - nginx, php-fpm, mariadb mysql, csf firewall etc or web app specific configurations are left to the Centmin Mod user to deal with. So I do not provide any free support for such.

    However, Centmin Mod users are free to help each other out and ask questions or give answers on this community forum. My hopes are that this community forum evolves so that more veteran long time Centmin Mod users help new Centmin Mod users out :)
     
  8. dcg

    dcg Member

    67
    24
    8
    Oct 17, 2015
    Florida, USA
    Ratings:
    +49
    Local Time:
    7:57 PM
    1.21.x
    10.3.x
    I found that I had to use named location in error_page setup with rewrite to get nginx to not display default error pages.

    Code:
    error_page 404 @404;
    
            location @404 {
                    access_log              off;
                    internal;
                    rewrite ^ /404.html break;
            }
    
     
  9. skringjer

    skringjer NoobMaster69

    208
    26
    28
    Apr 21, 2019
    Ratings:
    +43
    Local Time:
    4:57 AM
    Nginx 1.21.6
    MariaDB 10.3.x
    Thank you i will check if this works out for me
     
  10. skringjer

    skringjer NoobMaster69

    208
    26
    28
    Apr 21, 2019
    Ratings:
    +43
    Local Time:
    4:57 AM
    Nginx 1.21.6
    MariaDB 10.3.x
    It is PHP let me try your suggestion also thanks :)