Welcome! Log In Create A New Profile

Advanced

virtual host custom error page fails to display

Posted by thed 
virtual host custom error page fails to display
January 10, 2025 03:26AM
hi there. an nginx neophyte here.

i seem to have a problem having my custom error page display for my virtual host.

the error page (error.html) resides in /some/path/outside/of/var/www/html/

the custom error page (error.html) is displayed with my default server block code (and triggered using http://myipaddress/missingpage.html, where missingpage.html doesn't exist), but fails to show using the virtual host server block shown below (and triggered using https://somedomain.tld/missingpage.html):

server {

listen 80;
listen 443 ssl;

ssl_certificate /some/path/to/ssl/certificate/certificate.pem;
ssl_certificate_key /some/path/to/ssl/certificate//privatekey.pem;

root /some/path/to/domain/html/files;
index index.html;

server_name somedomain.tld;

location / {
try_files $uri $uri/ =404;
}

location ~ ^/scripts/.*\.pl$ {
gzip off;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_index index.pl;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

include /etc/nginx/custom/customerrorpage.conf;

}



where customerrorpage.conf contains the following content

error_page 404 405 500 501 /error.html;
location /error.html {
root /some/path/outside/of/var/www/html/;
internal;
}



when expecting a 404 (page not found) error, my custom error page is not shown, but instead i see the nginx output "404 Not Found" being displayed.

i've tried all manner of combos regarding error page location (inside and outside of /var/www/html/), code placement, file permissions/ownerships, etc. but i can't seem to get my custom error page being displayed for my virtual host code block.

with all of my attempted code combos, when applied to the default server block (and triggered using http://myipaddress/missingpage.html), the custom error page is always shown, but is never shown for my virtual host code block.

the (virtual host) domain functions as expected within web browsers, but that dang custom error page is a'hidin'

any suggestions would be greatly a'ppreciated.

thanks.

thed

.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 114
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready