雲計算

阿里雲如何添加二級域名及如何配置Ngnix解析域名(圖文教程)

  1. 阿里雲添加二級域名的操作:

一般一個域名會對應一個服務器,有時候為了項目的擴展,需要增加二級域名進行,以下步驟將教會如何配置二級域名。

登錄阿里雲,進入控制檯,選擇雲解析DNS,

image.png

選擇右側的解析管理,進行二級域名的添加


image.png

添加成功後,一般15分鐘內可以生效,不過時間也有可能更長。

2.nginx配置指向二級域名:

server {

listen 80;

server_name zhangruojun.com;

location / {

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header Host $http_host;

proxy_pass http://127.0.0.1:2368; 

}

}

server {

listen 80;

server_name demo.zhangruojun.com;

location / {

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header Host $http_host;

proxy_pass http://127.0.0.1:8000; 

}

}

如果服務器只有一個tomcat,可以這樣配置:

      server{
      listen 80;
      server_name test.wsta.net;
      location /{
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header Host $http_host;
            proxy_pass http://10.10.10.10:8080/Health/index.jsp;
      }

       location /Health {
            proxy_pass http://10.10.10.10:8080/Health;
       }

    }

雲服務器ECS地址:阿里雲·雲小站

Leave a Reply

Your email address will not be published. Required fields are marked *