【发布时间】:2020-10-05 01:01:57
【问题描述】:
所以我有一个带有ISS-10 的Web 应用程序,在wwww.mymindmapper.com 上运行并在port:80 上收听。我有两个简单的页面(login.html & register.html)。这是它的样子:https://imgur.com/a/gb9KAsj
我的主要目标是尝试找出如何在位于port: 80 的 IIS 上使用我的 webApp 创建 Node JS 服务器 (port: 81)。这是我的app.js 文件:
//USE `nodemon scripts/server.js` on Terminal to refresh Node Server on File Save.
//USE 'pm2 start scripts/server.js' on Terminal to start pm2 for IIS ??????????????????
//Import Node JS modules
const express = require("express");
const morgan = require("morgan");
const mysql = require("mysql");
//Create a new instance of express()
const app = express();
//GET INFORMATION ABOUT THE SERVER REQUESTS (OS, Browser, time, Internal Errors, Status Codes)
app.use(morgan('short')); //'short', 'combined'
//Require files from folder public (THIS CONTAINS ALL .html files inc. login.html and register.html)
app.use(express.static('./public'));
//Listen on PORT:80 with a callback function
app.listen(81, ()=>{
console.log("Server running on port 81");
});
请注意,当我通过 Visual Studio Code 上的终端发出请求时,一切正常。可以从我的数据库中添加/删除数据。 (我使用 XAMPP - Apache 监听 port:80 而 mMySQL 监听 port:3306)。
我在某处读到,这可以通过 IIS 上的 Reverse Proxy 来解决。但是,这似乎不起作用。此外,当我进行反向代理配置时,刷新页面时会出现以下错误。
【问题讨论】:
-
我有一个在 IIS 上运行 NodeJS 的站点,我们使用 IIS Node 来管理它:github.com/Azure/iisnode 我没有设置站点,所以我不是 100% 的配置。
-
在这个问题的各个方面,您都声称 IIS 在端口 80 上运行,而 Apache 在端口 80 上运行。它是哪一个?您在处理多台计算机吗?您是否在它们两个上都运行过您的 Node 应用程序?
-
@AdrianJ.Moreno,谢谢。我去看看。
-
@Quentin 感谢您的回复。不,只有一台电脑。我不确定这是如何工作的。当我去
localhost:80XAMPP 欢迎页面加载,当我尝试mymindmapper.com它加载我的webApplication。这也可以同时工作。 -
@AdrianJ.Moreno 我刚刚在 IIS 中检查了我的 WebApp 上的模块,但
iisnode不存在。这是我想要包含的内容吗?
标签: javascript node.js port reverse-proxy iis-10