node.js - nodejs应用 nginx部署多个node应用网站
PHPz
PHPz 2017-04-17 15:33:37
0
1
492

有两个域名
a.com
b.com

一个阿里云空间
www目录下有 aaa文件夹放网站a

a.conf如下

server {
    listen 80;
    server_name a.com;

    location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass         http://127.0.0.1:8082;
    }
}

aaa网站已经跑起来了

现在想在www目录新建bbb文件夹放网站b(也是node应用)并使用b.com访问,该怎么做
新建一个b.conf 还是在a.conf里面写 该如何写 对nginx一点不了解

PHPz
PHPz

学习是最好的投资!

reply all(1)
迷茫

It can be seen that the port used by the first Node application is 8082, so which port is used by the second Node application? I don't know, so I might as well assume that 8083 is used. Then the nginx configuration file is changed to:

server {
    listen 80;
    server_name a.com;

    location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass         http://127.0.0.1:8082;
    }
}

server {
    listen 80;
    server_name b.com;

    location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass         http://127.0.0.1:8083;
    }
}

Then, just restart nginx. There is no need to create a new nginx configuration file.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template