将简单的nodejs应用程序部署到我的uni linux vm

时间:2019-04-11 17:25:03

标签: node.js nginx web-deployment

我可以从uni访问vm linux机器,并且必须将简单的nodejs应用程序部署到它。我可以SSH虚拟机和所有设备,并且已经在上面安装了Nginx,但是每当我尝试运行一个简单的“ hello world”节点应用程序并从家里的浏览器访问它时,我都会被重定向到在线其他站点,或者没有任何反应。

这是我的Nginx配置文件

# the nginx server instance

server {

listen 80;

listen [::]:80;

server_name fff.com www.fff.com;

access_log /var/log/nginx/yourdomain.com.log;



# pass the request to the node.js server with the correct headers

# and much more can be added, see nginx config options

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_fff/;

proxy_redirect off;

}

}

和我的hello world应用

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/');

我运行了该应用程序,可以从另一个ssh中卷曲它,但是当我转到fff.com时,我无法访问该网站或将其重定向到普通网站。

我在做什么错???如何在我的uni linux vm上键入host这个愚蠢的应用程序,并从家里的浏览器访问它?

0 个答案:

没有答案
相关问题