简体   繁体   English

Nginx proxy_reverse 和节点服务器。 您在哪里看到来自上游节点服务器的控制台日志 OUTPUT?

[英]Nginx proxy_reverse and node server. Where do you see the console log OUTPUT from upstream NODE server?

I come from windows server world.我来自 windows 服务器世界。 First time to use Nginx and so far, it's impressive but I have an issue and that's why I'm here;)第一次使用 Nginx 到目前为止,这令人印象深刻,但我有一个问题,这就是我在这里的原因;)

I've Ubuntu 20.04, Nginx and deployed an expressjs app (node), followed all the tutorials out there to setup Nginx and a proxy_reverse server.我已经安装了 Ubuntu 20.04、Nginx 并部署了 expressjs 应用程序(节点),然后按照所有教程设置 Z62E0B5B350C9E3D2C19AA801D9442BAZ9 和 proxy_reverse 服务器It works and I'm able to see and run/interact with my expressjs app routes (home, signin, signup...etc)它有效,我能够查看并运行/与我的 expressjs 应用程序路由(家庭、登录、注册......等)进行交互

My only issue is I can't see the results of console.log I placed in my routes (my node server) Get route example:我唯一的问题是我看不到我放置在路由(我的节点服务器)中的 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')
})

How do I view the result of that route if my node server is behind the Nginx server?如果我的节点服务器位于 Nginx 服务器之后,如何查看该路由的结果? Is there a way that makes Nginx display those logs to me (the admin)?有没有办法让 Nginx 向我(管理员)显示这些日志?

There are trillions of tutorials out there about how to add nginx as proxy but not one of them talk about this important issue.有数以万亿计的教程关于如何添加 nginx 作为代理,但其中没有一个谈论这个重要问题。 If you have a link that I can read or if you're experienced enough with Nginx proxy_reverse log operations, please explain in details or show me in code how do you view the console.log from the expressjs routes.如果您有我可以阅读的链接,或者您对 Nginx proxy_reverse 日志操作有足够的经验,请详细解释或用代码告诉我如何从 expressjs 路由查看 console.log。

So, my question is how do I see that console.log in the example above output?所以,我的问题是如何在上面的示例 output 中看到 console.log? Is it Nginx parameter, here is my server setup /etc/nginx/sites-available/default (I deleted irrelevant parts):是 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;
    }
}

Is there a directive in the context of location/server that I need to allow passing logs from the node/expressjs server to nginx shell or to anywhere to see what's going on with node/express routes?在 location/server 的上下文中是否有一条指令,我需要允许将日志从 node/expressjs 服务器传递到 nginx shell 或任何地方以查看 node/express 路由发生了什么? Is it in the nginx logs somewhere that I need to be aware of?是否在我需要注意的 nginx 日志中?

For anyone starting with this stack, pm2 logs when you inside your app directory will print logs to your console.对于从这个堆栈开始的任何人,当您进入您的应用程序目录时,pm2 日志会将日志打印到您的控制台。

my_app_directory  pm2 logs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 代理服务器收到来自上游服务器的无效响应。 节点JS - The proxy server received an invalid response from an upstream server. Node JS 用于节点服务器的 Nginx 反向代理为 css/js 文件返回 404 - Nginx Reverse Proxy for node server returning 404 for css/js files 使用Nginx的Node.js服务器上的反向代理? - Reverse proxy on a Node.js server using Nginx? 如何从作为nodejs服务器的反向代理的nginx服务器提供静态文件? - How do you serve static files from an nginx server acting as a reverse proxy for a nodejs server? 上游节点服务器关闭与Nginx的连接 - Upstream Node server closing connection to nginx 您在 POST 请求 NodeJS 快速服务器中的哪里看到 console.log 语句? - Where do you see console.log statements inside a POST request NodeJS express server? Node.js 查看控制台日志的位置 - Node.js see where the console was log 使用nginx + passenger时,如何在node express应用程序中看到console.log输出 - How can I see console.log output in a node express app when using nginx + passenger 对于在 Node.JS 上运行的 SaaS,是否需要 Web 服务器 (nginx) 或清漆作为反向代理? - For a SaaS running on Node.JS, is a web-server (nginx) or varnish necessary as a reverse proxy? 为什么我的Nginx反向代理node.js + express服务器重定向到0.0.0.0? - Why is my Nginx reverse-proxy node.js+express server redirecting to 0.0.0.0?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM