我怎么航线多个域到多个节点的应用程序? [英] how do I route multiple domains to multiple node applications?

查看:130
本文介绍了我怎么航线多个域到多个节点的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经习惯了托管环境中,你只需点击的cPanel的几个按钮典型的灯网页​​和您的域名被划并映射到htdocs目录内的文件夹。我一直在使用Node.js的很多,它似乎并没有那么简单做同样的事情。如果我有多个节点的应用程序,我想航线domain1.com:80和domain2.com:80每至其自己的节点的应用程序和端口,我怎么去这样做?我从哪里开始?

I'm used to the typical lamp web hosting environment where you just click a few buttons in cpanel and your domain gets zoned and mapped to a folder within htdocs. I've been using node.js a lot and it doesn't seem as simple to do the same thing. If I had multiple node apps and I wanted to route domain1.com:80 and domain2.com:80 each to its own node app and port, how do I go about doing that? where do I start?

推荐答案

这通常与nginx的完成。 Nginx的是一个反向代理,一个软件你把盈方Node.js的。

This is typically done with nginx. Nginx is a reverse proxy, a piece of software you put infront node.js.

server {
    listen      80;
    server_name www.domain1.com;
    root /var/www/domain1;

    location / {
        proxy_pass http://localhost:1337; # this is where your node.js app_domain1 is listening
    }
}

server {
    listen       80;
    server_name www.domain2.com;
    root /var/www/domain2;

    location / {
        proxy_pass http://localhost:1338; # this is where your node.js app_domain2 is listening
    }
}

从这里开始:对同一IP Nginx的不同域

这篇关于我怎么航线多个域到多个节点的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆