一台服务器上的多个节点应用程序,Nginx仅为一个站点

时间:2017-12-18 20:51:18

标签: node.js express nginx server port

我有一台服务器,我想用它来托管两个节点应用程序,但无论我做什么,我的第二个域都在为domain1.com提供服务。

我希望节点应用在domain1.com上,在domain2.com上有一个。

以下是配置:

domain1.com

server {
        listen 80;
        listen [::]:80;
        server_name www.domain1.com;
        return 301 https://$server_name$request_uri;

}



server {

        listen 443 ssl;
        listen [::]:443 ssl;

        # Add index.php to the list if you are using PHP
        # index index.html index.htm index.nginx-debian.html;

        server_name www.domain1.com;

        location / {
                proxy_pass http://127.0.0.1:3000/;
                include /etc/nginx/proxy_prams;
        }

}

domain2.com

server {
        listen 80;
        listen [::]:80;
        server_name www.domain2.com;
        return 301 https://$server_name$request_uri;

}



server {

        listen 443 ssl;
        listen [::]:443 ssl;

        # Add index.php to the list if you are using PHP
        # index index.html index.htm index.nginx-debian.html;

        server_name www.domain2.com;

        location / {
                proxy_pass http://127.0.0.1:3002/;
                include /etc/nginx/proxy_prams;
        }

}

以下是domain2.com的快速设置

let port = (3002);
app.set('port', port);

/**
 * Create HTTP server.
*/

var server = http.createServer(app);

如您所见,我在nginx服务器块中设置了端口,但只提供了domain1.com。任何人都可以帮忙吗?

0 个答案:

没有答案