簡體   English   中英

Node.JS 不為 IIS 上的端口 80 提供服務

[英]Node.JS not serving port 80 on IIS

我在 Windows Server 2019 上完全停止了 IIS,並在端口 80 上為我的 NodeJS 應用程序提供服務,如下所示:

const express= require('express');
const app=express();
...
...
...
const hostname = '0.0.0.0';
const port = 80;
app.listen(port, hostname, () => {
        console.log(`Server running at http://${hostname}:${port}/`);
});

但是 Node 並沒有遠程服務。 它適用於 localhost:80

我根據我在 StackOverflow 找到的答案設置了主機名 = '0.0.0.0'。 服務器的公共 IP 也不起作用。

打開 IIS 並設置站點時,我可以看到一個 index.html 文件就好了,所以端口 80 可以工作。

是服務器問題,還是 node.js 問題?

我開始節點

node index.js

謝謝。

對於那些面臨這個問題的人,我按照 Tadman 在上述評論中的建議進行了修復:配置 IIS 進行轉發(通過安裝應用程序請求路由和 URL 重寫 IIS 擴展)。

Node.js also worked when creating a new rule at Windows firewall for enabling port 80. The default rule at the firewall for port 80 will work only with IIS, not with Node.js.

至於上面提到的擴展,這里有一個關於如何安裝和設置的很好的指導:

https://dev.to/petereysermans/hosting-a-node-js-application-on-windows-with-iis-as-reverse-proxy-397b

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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