通过IIS部署Node.js服务器 - 如何运行服务器?

时间:2021-01-28 23:13:55

I'm trying to set up a production Node.js server on IIS with the plugin IISnode as specified here: http://www.amazedsaint.com/2011/09/creating-10-minute-todo-listing-app-on.html

我正在尝试使用此处指定的插件IISnode在IIS上设置生产Node.js服务器:http://www.amazedsaint.com/2011/09/creating-10-minute-todo-listing-app-on html的

What I don't understand is how I run my Server.js file. The example here shows the user links to the hello.js file in the url, but how do I run it as I run my node service locally? I normally just open up a command prompt window and run "nodemon server.js", but IIS has changed the process considerably.

我不明白的是我如何运行我的Server.js文件。此处的示例显示了用户指向url中hello.js文件的链接,但是如何在本地运行节点服务时运行它?我通常只是打开一个命令提示符窗口并运行“nodemon server.js”,但IIS已经大大改变了这个过程。

1 个解决方案

#1


2  

I believe that the way 'iisnode' works is that it intercepts requests for files with ".js" extension. I do not think it can be set up to run same way as you would run it using node or nodemon.

我相信'iisnode'的工作方式是拦截对扩展名为“.js”的文件的请求。我不认为它可以设置为使用与使用node或nodemon运行它相同的方式运行。

In my case I set up a production Node.js server with IIS by doing the following:

在我的例子中,我通过执行以下操作设置了一个带IIS的生产Node.js服务器:

  1. I set up my port in server.js to run on different port (say 81) so that it does not interfere with IIS.

    我在server.js中设置我的端口以在不同的端口(例如81)上运行,这样它就不会干扰IIS。

  2. I set up node to run in a service, so that it auto-restarts when server restarts, console window will not get closed accidently, etc (there are few options you can use - for example http://nssm.cc/ but we wrote our own wrapper service).

    我将节点设置为在服务中运行,以便在服务器重新启动时自动重新启动,控制台窗口不会意外关闭等(您可以使用的选项很少 - 例如http://nssm.cc/但我们写了我们自己的包装服务)。

  3. I set up forwarding from IIS to that node server - that way I could still use port 80 for the site externally and I was able to use host header filtering (there are multiple sites running on one server)

    我设置从IIS到该节点服务器的转发 - 这样我仍然可以在外部使用端口80,我可以使用主机头过滤(在一台服务器上运行多个站点)

#1


2  

I believe that the way 'iisnode' works is that it intercepts requests for files with ".js" extension. I do not think it can be set up to run same way as you would run it using node or nodemon.

我相信'iisnode'的工作方式是拦截对扩展名为“.js”的文件的请求。我不认为它可以设置为使用与使用node或nodemon运行它相同的方式运行。

In my case I set up a production Node.js server with IIS by doing the following:

在我的例子中,我通过执行以下操作设置了一个带IIS的生产Node.js服务器:

  1. I set up my port in server.js to run on different port (say 81) so that it does not interfere with IIS.

    我在server.js中设置我的端口以在不同的端口(例如81)上运行,这样它就不会干扰IIS。

  2. I set up node to run in a service, so that it auto-restarts when server restarts, console window will not get closed accidently, etc (there are few options you can use - for example http://nssm.cc/ but we wrote our own wrapper service).

    我将节点设置为在服务中运行,以便在服务器重新启动时自动重新启动,控制台窗口不会意外关闭等(您可以使用的选项很少 - 例如http://nssm.cc/但我们写了我们自己的包装服务)。

  3. I set up forwarding from IIS to that node server - that way I could still use port 80 for the site externally and I was able to use host header filtering (there are multiple sites running on one server)

    我设置从IIS到该节点服务器的转发 - 这样我仍然可以在外部使用端口80,我可以使用主机头过滤(在一台服务器上运行多个站点)