LoginSignup
5

More than 5 years have passed since last update.

nginx、50x系のレスポンス用のhtmlはあるけど403,4系のやつってどこから返してるの

Posted at

という些細な疑問。適当にどっかから撮ってきてるのかと思って探したら案外無くてムキになって探してしまった。↓みたいなやつのことです。

image

A: nginx/src/http/ngx_http_special_response.c内でハードコーディングされてた。

ngx_http_special_response.c
static char ngx_http_error_403_page[] =
"<html>" CRLF
"<head><title>403 Forbidden</title></head>" CRLF
"<body bgcolor=\"white\">" CRLF
"<center><h1>403 Forbidden</h1></center>" CRLF
;


static char ngx_http_error_404_page[] =
"<html>" CRLF
"<head><title>404 Not Found</title></head>" CRLF
"<body bgcolor=\"white\">" CRLF
"<center><h1>404 Not Found</h1></center>" CRLF
;

こういうのがngx_http_send_special_responseとかいう関数で呼ばれてるらしい(C-fで流し読んだ並感)とりあえず出処がわかってなるほど、と落ち着いたが案外こういう疑問の掘り下げでソースコード・リーディング進めたほうがいいのかもなあと少し。漫然に読むって言ってもダレること多いしね。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5