nginx禁止未綁定網域名稱訪問

來源:互聯網
上載者:User

nginx 只允許某些網域名稱訪問 其他一律不能訪問 ,是怎麼寫的? 對於這個問題可以參考官方文檔 In catch-all server examples the strange name “_” can be seen: server {    listen       80  default_server;    server_name  _;    return       444;}There is nothing special about this name, it is just one of a myriad of invalid domain names which never intersect with any real name. Other invalid names like “--” and “!@#” may equally be used.   在catch-all伺服器執行個體可以看出:奇怪的名字“ _ “ server {    listen       80  default_server;    server_name  _;    return       404;}這個名字沒有什麼特別的,它僅僅是一個許多無效的網域名稱中的一個代表與任何真實的名字,永遠不會相交。其它無效的名稱,如“ - “ 和” !@# “也可同樣使用。default_server:nginx的虛擬機器主機是通過HTTP請求中的Host值來找到對應的虛擬機器主機配置,如果找不到呢?那 nginx就會將請求送到指定了 default_server 的 節點來處理也就是對於未綁定的網域名稱指向你的伺服器時,匹配不到你配置的虛擬機器主機網域名稱後,會預設使用這個虛擬機器主機,然後直接返回404。 把這個配置添加你的nginx.conf即可

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.