【问题标题】:How to set up nodejs + nginx on windows 8如何在 Windows 8 上设置 nodejs + nginx
【发布时间】:2016-11-03 15:40:13
【问题描述】:

我在This tutorial 之后在 Windows 8 上使用 nodejs + nginx,并使用 this link 进行设置,我在端口“http://127.0.0.1:3000/”和端口“3000”处得到“Hello World”但是在“http://robstodo.com/”它不起作用,因为我编写了启动 nginx 服务器的命令:- 启动 nginx 只有黑屏在闪烁,我怎么知道我的应用程序正在 nginx 服务器上运行?我应该在哪个文件中更改。它是我的 server.js

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(3000, '127.0.0.1');
console.log('Server running at http://127.0.0.1:3000/');

这是我的 nginx.conf

http {
  //server_names_hash_bucket_size 64;
  //...
  upstream app_robstodo {
    server 127.0.0.1:3000;
  }

  server {
    listen 80;
    server_name www.robstodo.com robstodo.com;
    access_log /path/to/logs/nginx/minitorials.log;

    location / {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_set_header X-NginX-Proxy true;

      proxy_pass http://app_robstodo/;
      proxy_redirect off;
    }
  }
}

请帮帮我,我现在卡住了。

【问题讨论】:

  • 您是否将 dommain www.robstodo.com 指向您的 Windows 8?在 Windows 8 中使用 hosts 文件将您的域添加到 127.0.0.1
  • @ThanhNguyenVan 我将在 Windows 8 中指向哪里?这里将使用 windows 中的 hosts 文件?

标签: javascript node.js nginx nginx-location


【解决方案1】:

对于您的域的临时测试,您应该在 windows 8 中使用hosts 文件。

C:\Windows\System32\drivers\etc

在hosts文件中添加:

127.0.0.1 robstodo.com

然后保存并再次访问http://robstodo.com/

将您的域指向网络服务器(在这种情况下,Windows 8 是网络服务器)

  1. 您应该在域控制面板中create A record
  2. 在网络服务器旁边的路由器上配置Port forwarding

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-24
  • 2014-07-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-01-11
相关资源
最近更新 更多