问题
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 ? and in which file should i change. Its my 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
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.
回答1:
For temporary test with your domain, you should use hosts
file in windows 8.
C:\Windows\System32\drivers\etc
In hosts file add:
127.0.0.1 robstodo.com
Then save, and access http://robstodo.com/ again.
For point your domain to web-server (in this case, windows 8 is webserver)
- You should create A record in domain control panel.
- Configure Port forwarding on your router which beside the webserver
来源:https://stackoverflow.com/questions/38141805/how-to-set-up-nodejs-nginx-on-windows-8