簡體   English   中英

Nginx proxy_reverse 和節點服務器。 您在哪里看到來自上游節點服務器的控制台日志 OUTPUT?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM