繁体   English   中英

节点:在不同的端口上设置不同的域名

[英]Node : Set different domain name on different port

我已经在node中创建了我的网站。 我在不同的模块上使用不同的端口。

http://localhost:5555/这是给管理员的,

http://localhost:5050/ ,用于客户端访问。”

我正在使用Digitalocean Ubuntu服务器,并且已经从Godaddy购买了域名。

我想在不同的端口上设置不同的域。

喜欢

http://localhost:5555/应该是“ http://admin.example.com ”。

http://localhost:5050/应该是“ http://example.com ”。

我曾在Ubuntu中尝试过nginx ,但没有任何用处。

请帮我 。 提前致谢。

您需要在nginx配置文件中进行两个server配置,一个用于admin子域,另一个用于example.com本身。 它看起来应该像这样:

    server {
    listen          80 default;
    server_name     example.com .example.com ;

    location / {

            proxy_pass http://localhost:5050;
            proxy_pass_header Server;
            proxy_redirect off;
            proxy_set_header Host $http_host;
            proxy_set_header X-Forwarded-For $remote_addr;
    }

   server {
    listen          80;
    server_name     admin.example.com;

    location / {

            proxy_pass http://localhost:5555;
            proxy_pass_header Server;
            proxy_redirect off;
            proxy_set_header Host $http_host;
            proxy_set_header X-Forwarded-For $remote_addr;
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM