簡體   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