![](/img/trans.png)
[英]The proxy server received an invalid response from an upstream server. Node JS
[英]Nginx proxy_reverse and node server. Where do you see the console log OUTPUT from upstream NODE server?
我来自 windows 服务器世界。 第一次使用 Nginx 到目前为止,这令人印象深刻,但我有一个问题,这就是我在这里的原因;)
我已经安装了 Ubuntu 20.04、Nginx 并部署了 expressjs 应用程序(节点),然后按照所有教程设置 Z62E0B5B350C9E3D2C19AA801D9442BAZ9 和 proxy_reverse 服务器它有效,我能够查看并运行/与我的 expressjs 应用程序路由(家庭、登录、注册......等)进行交互
我唯一的问题是我看不到我放置在路由(我的节点服务器)中的 console.log 的结果获取路由示例:
app.get('/', function (req, res) {
console.log("db is connected, user is loggedin and we're ready to
go....wait...another issue with Nginx I need to research and I can't
find in the docs")
res.send('hello world')
})
如果我的节点服务器位于 Nginx 服务器之后,如何查看该路由的结果? 有没有办法让 Nginx 向我(管理员)显示这些日志?
有数以万亿计的教程关于如何添加 nginx 作为代理,但其中没有一个谈论这个重要问题。 如果您有我可以阅读的链接,或者您对 Nginx proxy_reverse 日志操作有足够的经验,请详细解释或用代码告诉我如何从 expressjs 路由查看 console.log。
所以,我的问题是如何在上面的示例 output 中看到 console.log? 是 Nginx 参数吗,这是我的服务器设置 /etc/nginx/sites-available/default (我删除了不相关的部分):
server {
listen 80 default_server;
listen [::]:80 default_server;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
在 location/server 的上下文中是否有一条指令,我需要允许将日志从 node/expressjs 服务器传递到 nginx shell 或任何地方以查看 node/express 路由发生了什么? 是否在我需要注意的 nginx 日志中?
对于从这个堆栈开始的任何人,当您进入您的应用程序目录时,pm2 日志会将日志打印到您的控制台。
my_app_directory pm2 logs
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.