【发布时间】: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