如何 运行 Nginx 与 Node.js on Windows?

How to run Nginx with Node.js on Windows?

我想在 Windows 上安装 Nginx,并在 运行 上安装两个节点应用程序。我该怎么做?

我试过下载 Nginx 1.6.3,但我没有找到关于如何在 Windows 上 运行 的相关信息。只为 Linux。我认为应该有一些节点模块。

任何建议都会有用!

这里有一些关于如何为 Windows 安装 nginx 的说明:

http://nginx.org/en/docs/windows.html

我从来没有在 Windows 上 运行 Nginx,但是官方文档说明了如何:http://nginx.org/en/docs/windows.html

对于运行两个带有Nginx的节点应用,需要创建一个代理。这是一个如何改变 nginx.conf 文件的例子:

worker_processes 1;

events {
        worker_connections 1024;
}
http {
        include mime.types;
        default_type application/octet-stream;
        sendfile on;
        keepalive_timeout 65;
        gzip on;
server {
        listen 80;
        server_name localhost;
        access_log C:\var\log\nginx\access.log;
                location ~ ^/(javascripts|stylesheets|images) {
                root C:\app1\public;
                expires max;
        }
        location / {
                proxy_pass http://localhost:3000;
        }
  }
server {
        listen 81;
        server_name localhost;
        access_log C:\var\log\nginx\access.log;
                location ~ ^/(javascripts|stylesheets|images) {
                root C:\app2\public;
                expires max;
        }
        location / {
                proxy_pass http://localhost:3001;
        }
  }
}

在这种情况下,有两个节点应用程序,一个 运行ning 在端口 3000 上,另一个在端口 3001 上 - Nginx 用作代理。

更多文档:https://www.nginx.com/blog/nginx-nodejs-websockets-socketio/.

在您的情况下,配置文件已本地化为:C:\nginx_v1_6\conf\nginx.conf

备份默认文件并用我发布的内容更新内容。

最后,你可以通过localhost(默认端口80)和localhost:81测试反向代理,如果节点服务器和Nginx服务器是运行ning。