nginx配置文件詳解

include mime.types; #引用服務器可以支持的文件類型
default_type application/octet-stream; #配置處理前端請求的MIME類型,#指定默認類型爲二進制流,也就是當文件類型未 定義時使用這種方式,例如在沒有配置PHP環境時,Nginx是不予解析的,此時,用瀏覽器訪問PHP文件就會出現下載窗口

#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
#                  '$status $body_bytes_sent "$http_referer" '
#                  '"$http_user_agent" "$http_x_forwarded_for"';  #日誌文件的格式

#access_log  logs/access.log  main;    #日誌文件存放的路徑

sendfile        on;                    #文件高效傳輸
#tcp_nopush     on;                    ## tcp_nopush,tcp_nodelay設置on,防止網絡阻塞

#keepalive_timeout  0;                  

client_header_timeout  10;#指定客戶端請求頭讀取超時時間,如果超過這個時間,客戶 端還沒有發送任何數據,Nginx將返回“Request time out(408)”錯誤
keepalive_timeout  65;                 #指定客戶端連接保持活動的超時時間

#gzip  on;                ##開啓gzip壓縮,實時壓縮輸出數據流

server {                  #server 模塊  虛擬主機
    listen       80;         #監聽端口
    server_name  localhost;     #請求的域名或者IP

    #charset koi8-r;           #指定Nginx默認的字符集,只有utf-8支持中文字符

    #access_log  logs/host.access.log  main;#指定日誌訪問的格式和位置

    location / {                         #捕獲/的請求 相當於server的指令
        root   html;                     #指定網頁的默認根目錄
        index  index.html index.htm;     #設定默認首頁
    }

    #error_page  404              /404.html;  #設置相應錯誤的對應網頁

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;  
    location = /50x.html {          捕獲/50x的請求
        root   html;                 
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {               #匹配以PHP結尾的URL
    #    proxy_pass   http://127.0.0.1;   #將請求發送給這個IP
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {          
    #    root           html;               #網站的根目錄
    #    fastcgi_pass   127.0.0.1:9000;     #通過fastcgi接口將請求發送給這個IP
    #    fastcgi_index  index.php;           #設置首頁
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;    # 在瀏覽器中訪問的.php文件,實際讀取的是 $document_root(網站根目錄)下的.php文件  
    #    include        fastcgi_params;    #引用這個文件
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {    #以~ /\.ht爲結尾的URL 全部拒絕訪問
    #    deny  all;
    #}
}

# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
#    listen       8000;
#    listen       somename:8080;
#    server_name  somename  alias  another.alias;

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

# HTTPS server
#
#server {
#    listen       443 ssl;
#    server_name  localhost;

#    ssl_certificate      cert.pem;
#    ssl_certificate_key  cert.key;

#    ssl_session_cache    shared:SSL:1m;
#    ssl_session_timeout  5m;

#    ssl_ciphers  HIGH:!aNULL:!MD5;
#    ssl_prefer_server_ciphers  on;

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

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章