Lighttpd 没有在任何地方打印 500 错误?

Lighttpd 没有在任何地方打印 500 错误?

我正在尝试使用 lighttpd 作为一些正在运行的节点的简单“活动”服务器。但是,我运行的脚本会非确定性地抛出 500 个错误,而我却无法在任何地方找到它们。

这是我的调试配置:

server.document-root = "/var/www/health_checker"

server.port = 44445
server.modules += ("mod_auth", "mod_rewrite", "mod_accesslog", "mod_cgi", "mod_redirect", "mod_status" )

cgi.assign = ( ".sh" => "/bin/sh" )

url.rewrite-once = (
      "^/healthz"  => "/healthz.sh",
      "^/.*" => "/livez.sh" 
)

server.error-handler-404   = "/livez.sh"
server.errorlog            = "/home/aronchick/temperror.log"
server.breakagelog         = "/home/aronchick/tempcgi.log"
server.accesslog           = "/home/aronchick/tempaccess.log"

debug.log-request-header             = "enable"
debug.log-request-header-on-error    = "enable"
debug.log-response-header            = "enable"
debug.log-file-not-found             = "enable"
debug.log-request-handling           = "enable"
debug.log-condition-handling         = "enable"
debug.log-condition-cache-handling   = "enable"
debug.log-ssl-noise                  = "enable"
debug.log-timeouts                   = "enable"

这是一个非确定性的例子:

aronchick@myservice-vm-0:~$ curl 0.0.0.0:44445/livez.sh
{ 'hostname': 'myservice-vm-0.us-east4-c.c.myservice-production.internal', 'date': '2022-06-19 19:38:37.445066814+00:00', 'ip': 'xx.xx.xx.xx'}
aronchick@myservice-vm-0:~$ curl 0.0.0.0:44445/livez.sh
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
  <title>500 Internal Server Error</title>
 </head>
 <body>
  <h1>500 Internal Server Error</h1>
 </body>
</html>
aronchick@myservice-vm-0:~$ curl 0.0.0.0:44445/livez.sh
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
  <title>500 Internal Server Error</title>
 </head>
 <body>
  <h1>500 Internal Server Error</h1>
 </body>
</html>
aronchick@myservice-vm-0:~$ curl 0.0.0.0:44445/livez.sh
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
  <title>500 Internal Server Error</title>
 </head>
 <body>
  <h1>500 Internal Server Error</h1>
 </body>
</html>
aronchick@myservice-vm-0:~$ curl 0.0.0.0:44445/livez.sh
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
  <title>500 Internal Server Error</title>
 </head>
 <body>
  <h1>500 Internal Server Error</h1>
 </body>
</html>
aronchick@myservice-vm-0:~$ curl 0.0.0.0:44445/livez.sh
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
  <title>500 Internal Server Error</title>
 </head>
 <body>
  <h1>500 Internal Server Error</h1>
 </body>
</html>
aronchick@myservice-vm-0:~$ curl 0.0.0.0:44445/livez.sh
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
  <title>500 Internal Server Error</title>
 </head>
 <body>
  <h1>500 Internal Server Error</h1>
 </body>
</html>
aronchick@myservice-vm-0:~$ 
aronchick@myservice-vm-0:~$ curl 0.0.0.0:44445/livez.sh
{ 'hostname': 'myservice-vm-0.us-east4-c.c.myservice-production.internal', 'date': '2022-06-19 19:38:37.445066814+00:00', 'ip': 'xx.xx.xx.xx'}
aronchick@myservice-vm-0:~$ ps aux

我甚至不知道 500 个错误写在哪里。以下是/home/aronchick/temperror.log

2022-06-19 19:29:37: (connections.c.771) fd:8 rqst: GET / HTTP/1.1
2022-06-19 19:29:37: (connections.c.771) fd:8 rqst: Host: 127.0.0.1:44445
2022-06-19 19:29:37: (connections.c.771) fd:8 rqst: User-Agent: curl/7.81.0
2022-06-19 19:29:37: (connections.c.771) fd:8 rqst: Accept: */*
2022-06-19 19:29:37: (connections.c.771) fd:8 rqst: 
2022-06-19 19:29:37: (response.c.407) -- parsed Request-URI
2022-06-19 19:29:37: (response.c.409) Request-URI     : /
2022-06-19 19:29:37: (response.c.411) URI-scheme      : http
2022-06-19 19:29:37: (response.c.413) URI-authority   : 127.0.0.1:44445
2022-06-19 19:29:37: (response.c.415) URI-path (clean): /
2022-06-19 19:29:37: (response.c.417) URI-query       : 
2022-06-19 19:29:37: (response.c.407) -- parsed Request-URI
2022-06-19 19:29:37: (response.c.409) Request-URI     : /livez.sh
2022-06-19 19:29:37: (response.c.411) URI-scheme      : http
2022-06-19 19:29:37: (response.c.413) URI-authority   : 127.0.0.1:44445
2022-06-19 19:29:37: (response.c.415) URI-path (clean): /livez.sh
2022-06-19 19:29:37: (response.c.417) URI-query       : 
2022-06-19 19:29:37: (response.c.495) -- logical -> physical
2022-06-19 19:29:37: (response.c.497) Doc-Root     : /var/www/health_checker
2022-06-19 19:29:37: (response.c.499) Basedir      : /var/www/health_checker
2022-06-19 19:29:37: (response.c.501) Rel-Path     : /livez.sh
2022-06-19 19:29:37: (response.c.503) Path         : /var/www/health_checker/livez.sh
2022-06-19 19:29:37: (response.c.522) -- handling subrequest
2022-06-19 19:29:37: (response.c.524) Path         : /var/www/health_checker/livez.sh
2022-06-19 19:29:37: (response.c.526) URI          : /livez.sh
2022-06-19 19:29:37: (response.c.528) Pathinfo     : 
2022-06-19 19:29:37: (response.c.164) fd:8 resp: HTTP/1.1 500 Internal Server Error
2022-06-19 19:29:37: (response.c.164) fd:8 resp: Content-Type: text/html
2022-06-19 19:29:37: (response.c.164) fd:8 resp: Content-Length: 365
2022-06-19 19:29:37: (response.c.164) fd:8 resp: Date: Sun, 19 Jun 2022 19:29:37 GMT
2022-06-19 19:29:37: (response.c.164) fd:8 resp: Server: lighttpd/1.4.63
2022-06-19 19:29:37: (response.c.164) fd:8 resp: 

答案1

如果您的脚本未能返回响应,那么 lighttpd 将返回 500 内部服务器错误。

CGI 脚本可能没有遵循CGI 规范

? 您的 CGI 脚本是否做了类似的事情:

printf "Status: 200\nContent-Type: application/json\n\n"

打印之前 { 'hostname': 'myservice-vm-0.us-east4-c.c.myservice-production.internal', 'date': '2022-06-19 19:38:37.445066814+00:00', 'ip': 'xx.xx.xx.xx'}

相关内容