简体   繁体   English

如何在Windows 8上设置Node.js + Nginx

[英]How to set up nodejs + nginx on windows 8

I am using nodejs + nginx on windows 8 following This tutorial and set up using this link i am getting " Hello World " at port " http://127.0.0.1:3000/ " and at port "3000" but at " http://robstodo.com/ " its not working as i write command for start nginx server :- start nginx only black screen is blinking , How i can know my app is running on nginx server ? 我在本教程后面的Windows 8上使用nodejs + nginx,并使用此链接进行设置,我在端口“ http://127.0.0.1:3000/ ”和端口“ 3000”处获得“ Hello World ”,但在“ http: //robstodo.com/ “在启动启动Nginx服务器的命令编写时不起作用:- 启动Nginx仅黑屏闪烁,我如何知道我的应用程序正在Nginx服务器上运行? and in which file should i change. 以及我应该更改哪个文件。 Its my server.js 它是我的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/'); 

It's my nginx.conf 这是我的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; } } } 

Please help me i got stucked at this point. 请帮助我,我现在被卡住了。

For temporary test with your domain, you should use hosts file in windows 8. 为了对您的域进行临时测试,应在Windows 8中使用hosts文件。

C:\Windows\System32\drivers\etc

In hosts file add: 在主机文件中添加:

127.0.0.1 robstodo.com

Then save, and access http://robstodo.com/ again. 然后保存,并再次访问http://robstodo.com/

For point your domain to web-server (in this case, windows 8 is webserver) 对于将您的域指向Web服务器(在这种情况下,Windows 8是Web服务器)

  1. You should create A record in domain control panel. 您应该在域控制面板中创建A记录
  2. Configure Port forwarding on your router which beside the webserver 在网络服务器旁边的路由器上配置端口转发

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM