Reputation: 63619
How can we configure a server to serve http://domain1.com using Meteor.js and http://domain2.com using nginx/apache?
Upvotes: 2
Views: 690
Reputation: 1234
Another other way to do this is let nginx handle the proxying and using virtual hosts to separate the traffic.
You'll need nginx 1.4.3 or newer to proxy websockets, and the following config will do it:
/etc/nginx/conf.d/upgrade.conf
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
/etc/nginx/sites-enabled/meteor
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;
}
}
and your nginx config for the Apache site would be the same as usual, but with server_name domain2.com;
or whatever you want to name it.
Upvotes: 1
Reputation: 75945
You could use a node-http-proxy script to do this or nginx.
A sample node-http-proxy script. Be sure to use the caronte branch will allows websockets to work with meteor without falling to long polling:
Sample node.js script
var httpProxy = require('http-proxy');
httpProxy.createServer({
router: {
'domain1.com': 'localhost:3000' //Meteor port & host
'domain2.com': 'localhost:8000' //Apache port & host
}
}).listen(80);
So the above would run on port 80. You would run meteor on port 3000 and apache/nginx on port 8000.
The proxy would check the domain hostname and if its domain1.com it would act as a transparent proxy to localhost:3000
Upvotes: 3