Meteor.js和Apache / Nginx在同一台服务器上提供不同的域名

我们如何configuration服务器使用Meteor.js和http://domain2.com使用nginx / apache来提供http://domain1.com ?

另一种方法是让nginx处理代理并使用虚拟主机来分离流量。

你需要nginx 1.4.3或更新的代理websockets,下面的配置会做到这一点:

/etc/nginx/conf.d/upgrade.conf

map $http_upgrade $connection_upgrade { default upgrade; '' close; } 

在/ etc / nginx的/启用的站点- /流星

 server { server_name domain1.com; # add_header X-Powered-By Meteor; location / { proxy_pass http://127.0.0.1:3000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; } } 

而你的Apache网站的nginx配置和往常一样,但是server_name domain2.com; 或者任何你想要命名的东西。

你可以使用node-http-proxy脚本来做这个或者nginx。

示例节点-http代理脚本。 一定要使用caronte分支将允许websockets与流星一起工作,而不会长时间投票:

示例node.js脚本

 var httpProxy = require('http-proxy'); httpProxy.createserver({ router: { 'domain1.com': 'localhost:3000' //Meteor port & host 'domain2.com': 'localhost:8000' //Apache port & host } }).listen(80); 

所以上面的代码会运行在80端口上。你可以在端口3000上运行meteor,在8000端口上运行apache / nginx。

代理将检查域名主机名,如果它的domain1.com将作为localhost:3000的透明代理