nginx中server配置簡單示例

Ubuntu14.04下的nginx配置(配置文件nginx.conf):

    server {
        listen       80;
        server_name  localhost;

        location / {
            root   html;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
1、上述配置中第一個location中的root指定與nginx同目錄下的html目錄,index指定默認的歡迎頁面爲index.html或index.htm。
2、error_page指定發生錯誤500 502 503 504後,轉向的頁面。50.html頁面同樣在html目錄下。
3、第二個location形式爲location = /50x.html,表示精準的匹配。
4、與server同級的可以有多個。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章