最近开始学习 Nodejs ,但是机子上已经有了 apache ,所以为了跑 Node ,就查询资料使用apache代理nodejs服务进行工作。
<VirtualHost *:80>
ServerName www.webtest.com
ServerAlias www.webtest.com
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
ProxyPass http://localhost:3000/
ProxyPassReverse http://localhost:3000/
</Location>
</VirtualHost>
在我们的 hosts 文件中增加:127.0.0.1 www.webtest.com
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
app.get('/', function(req, res){
res.send('<h1>Welcome Realtime Server</h1>');
});
http.listen(3000, function(){
console.log('listening on *:3000');
});
运行文件:
访问我们配置的虚拟主机 www.webtest.com
(adsbygoogle = window.adsbygoogle || []).push({});