在nginx中配置ip直接訪問的默認站點


 

 

 

 

一台機子部署多個網站,我們直接訪問ip (外網內網都一樣)提示無法訪問或404.

因為有多個網站,我們想指定某個網站為IP訪問默認的網站,如何操作呢?

 

解:在Listen ip:port; 這個指令行中,加參數default

這個server段就會是這個ip的默認站點

server {
        listen       80 default;
        server_name  web.com ;
        location / {
            root   F:/project/web;
            index  index.html index.htm index.php;
            autoindex  on;
        }
        location ~ \.php$ {
            root          F:/project/web;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM