Custom error pages

Has anyone tried to create custom error pages to replace the standard 404 and 500 error? I’d like to change the 500 message to be a maintenance page so that during upgrades the user doesn’t just see a 500 nginx error.

I’ve tried several different things that I’ve found online and nothing is working. I thought I could update the default file under /etc/nginx/sites-available. This is what I added above the “location /” line.

# custom error pages
error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 421 422 423 424 425 426 428 429 431 451 500 501 502 503 504 505 506 507 508 510 511 /er

ror.html;
location = /error.html {
ssi on;
internal;
}

Has anyone done this?

This is accomplished in either the nginx config or some sort of failover, which I’ve never messed with for a records.

For the nginx config, IIRC you can use error_page (see docs here), however this may be overwritten on updates.

Okay, I read your original post too quickly.

You are not currently editing a file that is in the nginx configuration.

I suspect the place to put this file is in /etc/nginx/nginx.conf in the http block.

I think something like:

# custom error pages
location / { error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 421 422 423 424 425 426 428 429 431 451 500 501 502 503 504 505 506 507 508 510 511 /error.html }

Although note that error_page does support named locations.

After making the change, be sure to run sudo nginx -t before reloading and also be very aware that any change to the configuration of MiaB, even through the GUI, may revert this edit - I’m not sure how often or when nginx.conf is rewritten.

If that doesn’t work, you will have to add it to the appropriate server block or blocks in /etc/nginx/conf.d/local.conf and that is clearly rewritten on a very regular basis.

These kinds of customizations are not what MiaB supports.