Sponsor:

Server and Web Integrator
Link:
Kloxo-MR logo
6.5.0 or 7.0.0
Click for "How to install"
Donation/Sponsorship:
Kloxo-MR is open-source.
Donate and or Sponsorship always welcome.
Click to:
Click Here
Please login or register. 2019-10-20, 08:07:22

Author Topic: How to config NGINX for custom 404 error page  (Read 305 times)

0 Members and 1 Guest are viewing this topic.

Offline rainwolf

  • Junior Member
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
How to config NGINX for custom 404 error page
« on: 2019-08-07, 08:19:18 »
how can i config NGINX  to show custom 404 error page, for only one of my clients on kloxo panel?i made a  " custom_404.html " file  in root directory  of domain and i found "Domainname.com.conf " file in this path : /opt/configs/nginx/conf/domains/ .
then i added this command :
Code: [Select]


error_page 404 /custom_404.html;
        location = /custom_404.html {
                root /usr/share/nginx/html;
                internal;
        }

to end of every functions that starts with "server" statement , in the file like this :
Code: [Select]

## cp for 'mydomainname.com'
server {
#disable_symlinks if_not_owner;

include '/opt/configs/nginx/conf/globals/listen_nonssl.conf';

include '/opt/configs/nginx/conf/globals/gzip.conf';

add_header X-Content-Type-Options "nosniff"
;
add_header X-XSS-Protection "1;mode=block"
;
add_header X-Frame-Options "SAMEORIGIN"
;
add_header Access-Control-Allow-Origin "*";
add_header X-Supported-By "Kloxo-MR 7.0";

server_name cp.mydomain.com;

include '/opt/configs/nginx/conf/globals/acme-challenge.conf';

index index.php index.shtml index.pl index.py index.cgi index.rb Default.aspx Default.asp index.html index.htm default.htm welcome.html;

set $var_domain 'cp.mydomain.com';
set $var_rootdir '/home/kloxo/httpd/cp';

root $var_rootdir;

set $var_user 'apache';
set $var_fpmport '50000';
set $var_phpselected 'php';

#include '/opt/configs/nginx/conf/globals/switch_standard.conf';
include '/opt/configs/nginx/conf/globals/php-fpm_standard.conf';

        error_page 404 /custom_404.html;
        location = /custom_404.html {
                root /usr/share/nginx/html;
                internal;
        }
}

then :
sh /script/restart-web -y
but nothing happens and kloxo 404 error page is showing up.
and after
sh /script/fixweb
the edited "Domainname.com.conf " will delete added script tho file.
any helps please!?

Online MRatWork

  • Administrator
  • The Elite
  • *****
  • Posts: 15,767
  • Karma: +119/-10
  • Gender: Male
    • View Profile
    • MRatWork Forum
Re: How to config NGINX for custom 404 error page
« Reply #1 on: 2019-08-07, 11:46:09 »
Copy Domainname.com.conf  from /opt/configs/nginx/conf/domains/ to /opt/configs/nginx/conf/customs and then edit Domainname.com.conf in  /opt/configs/nginx/conf/customs. Kloxo-MR will use file inside customs dir instead domains dir.
..:: MRatWork (Mustafa Ramadhan Projects) ::..
-- Server/Web-integrator - Web Hosting (Kloxo-MR READY!) --

Offline rainwolf

  • Junior Member
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: How to config NGINX for custom 404 error page
« Reply #2 on: 2019-08-07, 12:07:37 »
Copy Domainname.com.conf  from /opt/configs/nginx/conf/domains/ to /opt/configs/nginx/conf/customs and then edit Domainname.com.conf in  /opt/configs/nginx/conf/customs. Kloxo-MR will use file inside customs dir instead domains dir.
I`ve done this solution but unfortunately didn't work.

Online MRatWork

  • Administrator
  • The Elite
  • *****
  • Posts: 15,767
  • Karma: +119/-10
  • Gender: Male
    • View Profile
    • MRatWork Forum
Re: How to config NGINX for custom 404 error page
« Reply #3 on: 2019-08-07, 14:30:39 »
Rule for error pages in generic.conf inside /opt/configs/nginx/conf/globals.

If want customize for all domains, copy this generic.conf to custom.generic.conf and then edit custom.generic.conf. Kloxo-MR will be use this custom file instead their original.

After that, run 'sh /script/fixweb; sh /script/restart-web'.
..:: MRatWork (Mustafa Ramadhan Projects) ::..
-- Server/Web-integrator - Web Hosting (Kloxo-MR READY!) --

 


MRatWork Affiliates:    BIGRAF(R) Inc.    House of LMAR    EFARgrafix
Click Here

Page created in 0.028 seconds with 23 queries.

web stats analysis