Want to subscribe to topics you're interested in?
Become a Member

Nginx Custom Error Pages setup

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

  1. skringjer

    skringjer Premium Member Premium Member

    169
    19
    18
    Apr 21, 2019
    Ratings:
    +34
    Local Time:
    7:32 AM
    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 Premium Member Premium Member

    169
    19
    18
    Apr 21, 2019
    Ratings:
    +34
    Local Time:
    7:32 AM
    Any help please?
     
  3. skringjer

    skringjer Premium Member Premium Member

    169
    19
    18
    Apr 21, 2019
    Ratings:
    +34
    Local Time:
    7:32 AM
    I also googled and tried some methods but none work, will keep digging and update this page.
     
  4. skringjer

    skringjer Premium Member Premium Member

    169
    19
    18
    Apr 21, 2019
    Ratings:
    +34
    Local Time:
    7:32 AM
    No solutions found, any help would be appreciated
     
  5. skringjer

    skringjer Premium Member Premium Member

    169
    19
    18
    Apr 21, 2019
    Ratings:
    +34
    Local Time:
    7:32 AM
    @eva2000 sorry for tagging, but any clues im still trying to fix it.
     
  6. skringjer

    skringjer Premium Member Premium Member

    169
    19
    18
    Apr 21, 2019
    Ratings:
    +34
    Local Time:
    7:32 AM
    Could anyone help me out please?
     
  7. eva2000

    eva2000 Administrator Staff Member

    47,490
    10,762
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +16,730
    Local Time:
    12:32 PM
    Nginx 1.19.x
    MariaDB 5.5/10.x
    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 Premium Member Premium Member

    56
    19
    8
    Oct 17, 2015
    Florida, USA
    Ratings:
    +37
    Local Time:
    9:32 PM
    1.15.x
    10.2.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 Premium Member Premium Member

    169
    19
    18
    Apr 21, 2019
    Ratings:
    +34
    Local Time:
    7:32 AM
    Thank you i will check if this works out for me
     
  10. skringjer

    skringjer Premium Member Premium Member

    169
    19
    18
    Apr 21, 2019
    Ratings:
    +34
    Local Time:
    7:32 AM
    It is PHP let me try your suggestion also thanks :)