如何使nginx返回节点返回消息?

如何使nginx返回节点返回消息?,nginx,Nginx,我有一个nginx节点重定向到2个服务器节点,但是当我向nginx发送错误的http请求时,我发现nginx返回的消息没有用,例如下面的示例。我只需要查看来自服务器节点的错误消息,这些消息可能有助于调试 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>The page is temporarily unavailable</title>

我有一个nginx节点重定向到2个服务器节点,但是当我向nginx发送错误的http请求时,我发现nginx返回的消息没有用,例如下面的示例。我只需要查看来自服务器节点的错误消息,这些消息可能有助于调试

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <title>The page is temporarily unavailable</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <style type="text/css">
        /*<![CDATA[*/
        body {
            background-color: #fff;
            color: #000;
            font-size: 0.9em;
            font-family: sans-serif,helvetica;
            margin: 0;
            padding: 0;
        }
        :link {
            color: #c00;
        }
        :visited {
            color: #c00;
        }
        a:hover {
            color: #f50;
        }
        h1 {
            text-align: center;
            margin: 0;
            padding: 0.6em 2em 0.4em;
            background-color: #294172;
            color: #fff;
            font-weight: normal;
            font-size: 1.75em;
            border-bottom: 2px solid #000;
        }
        h1 strong {
            font-weight: bold;
            font-size: 1.5em;
        }
        h2 {
            text-align: center;
            background-color: #3C6EB4;
            font-size: 1.1em;
            font-weight: bold;
            color: #fff;
            margin: 0;
            padding: 0.5em;
            border-bottom: 2px solid #294172;
        }
        h3 {
            text-align: center;
            background-color: #ff0000;
            padding: 0.5em;
            color: #fff;
        }
        hr {
            display: none;
        }
        .content {
            padding: 1em 5em;
        }
        .alert {
            border: 2px solid #000;
        }

该页面暂时不可用
/*

我想问一下nginx.conf中是否存在一些可以实现该功能的配置。如何配置它?谢谢

nginx的默认行为是:显示来自上游(您的节点进程)的任何响应。如果绝对没有响应可用,则显示nginx错误消息

您看到的消息是针对我的,就像您的节点进程超时一样。如果它不可用,您将看到nginx 500

因此,您希望看到的节点错误应该已经发生了。但是,如果您的节点进程甚至不能提供错误,则不会发生这种情况。看起来这里就是这样


若要继续:请在节点服务器代码中插入一些文件日志语句,或为节点服务器设置远程分步调试,以了解其中的情况。

是否要设置自定义错误页?可能是这样的:您的意思是创建nginx-error.conf,它与nginx.conf位于同一个文件夹中?我已经尝试过了,它不起作用。谢谢,让我给您举个例子。当我向nginx节点发送http请求时,我看到了如上所示的错误消息。但是我向nginx重定向到的节点发送了相同的http请求,有如下错误消息:{“error”:“未知异常”,“errorMessage”:“无法反序列化java.util.ArrayList的实例超出值\u字符串标记\n在[Source:HttpInputOverHTTP@60578e2f[c=554,q=1,[0]=EOF,s=STREAM];行:1,列:514](通过引用链:java.util.ArrayList[0]),“errorClass:“com.fasterxml.jackson.databind.JsonMappingException”,“host”:null}显示错误消息需要多长时间(请在干净的匿名浏览器窗口中尝试)?不,我使用了“curl”命令,因此它与浏览器无关。我的意思是,当我向nginx节点发送http请求时,我希望获得重定向节点错误消息,而不是上面的nginx错误消息