Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nginx custom error configuration referencing a string vs a file

Tags:

nginx

I understand that I can set a file for a custom error page:

location / {
    error_page 404 = /mybad.html;
}

But I'd just like to instead provide my page override as text inline in the config file:

 location / {
    error_page 404 = "<H1>Sorry!</H1>"
}

Is this possible with nginx?

like image 772
Geremy Avatar asked Nov 30 '12 21:11

Geremy


1 Answers

location / {
    error_page 404 @sorry;
}

location @sorry {
    return 404 "<H1>Sorry!</H1>";
}
  • http://nginx.org/r/error_page
  • http://nginx.org/r/return
like image 91
VBart Avatar answered Nov 15 '22 11:11

VBart