天天看點

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

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

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

 登入

阿裡雲

,進入控制台,選擇雲解析DNS,

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

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

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

添加成功後,一般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;
           }
 
        }
 
           

1.

基于阿裡雲伺服器搭建寶塔面闆教程最全詳解(圖文)

繼續閱讀