2017-08-30 185 views

回答

1

這是一個虛擬主機,這意味着,在相同的nginx/IP,您可以承載多個網站。

因此,添加server_name有助於nginx將流量從一個網站分離到其他網站。所以,如果你有兩個街區

server { 
    listen  80; 
    server_name example.org www.example.org; 
} 

server { 
    listen  80; 
    server_name example1.org www.example2.org; 
} 

現在example.orgwww.example.org將由第一模塊和請求處理,以example1.orgwww.example2.org將第二塊來處理。還有其他選項,如使用掩碼*.example.com或使用模式~^ww[\d]\.example\.com

你可以在以下鏈接

https://nginx.org/en/docs/http/server_names.html

+0

呀更多的細節,我讀過的文檔,然後問這個問題。 DNS用於主機名和IP地址。 server_name中的「www.example.org」是否等於瀏覽器中的url?也許關鍵詞是「虛擬主機」。 – user7328234

+0

是的,如果你瀏覽'http:// www.example.org /'server_name是'www.example.org' –

+0

如果「www.google.com」是sever_name的值,是否意味着流量會經過這個當用戶在瀏覽器中輸入此網址時,機器?當然不是,我錯過了什麼? – user7328234

相關問題