我有我的機器上運行的Apache,我必須運行我的應用程序,而無需添加端口號。如何在默認端口上設置節點js應用程序?
當我用下面從http://localhost:2121訪問它的工作原理:(後面沒有端口號)
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('hello');
}).listen(2121);
console.log('Server running');
我將它設置爲使用http://localhost如何
的可能的複製[Node.js的 - 我如何從URL刪除端口?] (http://stackoverflow.com/questions/9526500/node-js-how-can-i-remove-the-port-from-the-url) –
你只是'.listen(80)' - 但是,如果apache在端口80上運行已經無法工作,因爲您不能讓兩臺服務器在同一個端口上偵聽。 – MrWillihog
可能是時候瞭解更多關於** Apache mod-proxy **的附加組件,以及如何將流量從80重新定向到:2121 –