欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Nginx服務(wù)器配置文件完全解析

 更新時(shí)間:2015年08月15日 15:41:40   投稿:goldensun  
這篇文章主要介紹了Nginx服務(wù)器配置文件完全解析,Nginx的異步非阻塞特性使其擁有非常出色的性能,需要的朋友可以參考下
user www www; // 使用的用戶和組
 
worker_processes 8; // 指定的工作衍生進(jìn)程數(shù)(一般等于cpu總核數(shù)或總核數(shù)的2倍)
 
error_log logs/nginx_error.log crit; // 指定錯(cuò)誤日志存放的路徑,錯(cuò)誤日志記錄級(jí)別分別選項(xiàng)為:debug,info,notice,warn,error,crit 
 
#error_log logs/error.log;
 
#error_log logs/error.log notice;
 
#error_log logs/error.log info;
 
 
pid     nginx.pid; // 指定pid文件存放的路徑
 
#pid    logs/nginx.pid;
 
 
worker_rlimit_nofile 65535; // 一個(gè)nginx進(jìn)程打開的最多文件描述符數(shù)目,理論值是最多打開的文件數(shù)(系統(tǒng)ulimit -n)與nginx進(jìn)程數(shù)相除,但是nginx分配請(qǐng)求并不均勻,所以在這里建議和ulimit 值保持一致
 
 
events {
   
  use  epoll; // 使用網(wǎng)絡(luò)I/O模型,Linux系統(tǒng)推薦采用epoll模型,FreeBSD系統(tǒng)推薦采用kqueue模型
  
  worker_connections 51200; // 允許的連接數(shù)
}
 
# 設(shè)定http服務(wù)器,利用它的反向代理功能提供負(fù)載均衡支持
http {
   
  include    mime.types; // 設(shè)定mime類型,類型由mime.type文件定義
  default_type application/octet-stream;
   
   
  charset utf-8; // 設(shè)置使用的字符集,如果一個(gè)網(wǎng)站有多種字符集,請(qǐng)不要隨便設(shè)置,應(yīng)該讓程序員在HTML代碼中通過Meta標(biāo)簽設(shè)置
   
  ssi on; // 頁(yè)面靜態(tài)化的一個(gè)大問題是登陸用戶訪問如果靜態(tài)化,大部分頁(yè)面內(nèi)容需要緩存但是用戶登陸的個(gè)人信息是動(dòng)態(tài)的,ssi用來(lái)解決頁(yè)面部分緩存問題
   
  ssi_silent_errors on; // 默認(rèn)是off,開啟后在處理SSI文件出錯(cuò)時(shí)不輸出錯(cuò)誤提示:"[an error occurred while processing the directive]"
  
  ssi_types text/shtml; // 默認(rèn)是ssi_types text/html,所以如果需要htm和html支持,則不需要設(shè)置這句,如果需要shtml支持,則需要設(shè)置
 
  #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指令指定nginx是否調(diào)用sendfile函數(shù)來(lái)輸出文件,對(duì)于普通應(yīng)用設(shè)為on,如果用來(lái)進(jìn)行下載等應(yīng)用磁盤IO重負(fù)載應(yīng)用,可設(shè)置為off,以平衡磁盤與網(wǎng)絡(luò)I/O處理速度,降低系統(tǒng)的負(fù)載,如果圖片顯示不正常把這個(gè)改成off
  sendfile    on;
 
  #tcp_nopush   on; // 防止網(wǎng)絡(luò)阻塞
 
  #tcp_nodelay on;
   
  # autoindex off; // 開啟目錄列表訪問,合適下載服務(wù)器,默認(rèn)關(guān)閉
   
  server_names_hash_bucket_size 128; // 服務(wù)器名字的hash表大小
   
  client_header_buffer_size 32k; // 上傳文件大小限制
   
  large_client_header_buffers 4 32k; // 設(shè)定請(qǐng)求緩存
   
  client_max_body_size 300m; // 設(shè)定請(qǐng)求緩存
   
  # (與php-fpm有關(guān)) 優(yōu)化的上傳支持,可以加速對(duì)大POST 請(qǐng)求的處理速度,包括文件上傳。優(yōu)化是通過將請(qǐng)求體已寫入一個(gè)臨時(shí)文件,然后fastcgi 協(xié)議傳遞文件名而不是請(qǐng)求體到來(lái)實(shí)現(xiàn)的
  client_body_in_file_only clean;
 
  client_body_temp_path /dev/shm 1 2;
 
  # 這個(gè)參數(shù)設(shè)置比較大時(shí),使用firefox或ie提交一個(gè)小于512K的圖片訪問都會(huì)正常,注釋改指令模式大小是操作系統(tǒng)頁(yè)面大小的兩倍,8K或16K ,一般提交的圖片大于512K,提交的內(nèi)容會(huì)寫入到臨時(shí)的文件,不會(huì)出現(xiàn)任何問題。當(dāng)取消了目錄訪問權(quán)限(autoindex off;),如果提交的圖片大于512K 都會(huì)返回500 Internal Server Error錯(cuò)誤
  client_body_buffer_size 512k;
 
   
  proxy_connect_timeout  5; // 后端服務(wù)器連接的超時(shí)時(shí)間_發(fā)起握手等候響應(yīng)超時(shí)時(shí)間(代理連接超時(shí))
 
   
  proxy_read_timeout    60; // 連接成功后_等候后端服務(wù)器響應(yīng)時(shí)間_其實(shí)已經(jīng)進(jìn)入后端的排隊(duì)之中等候處理(后端服務(wù)器處理請(qǐng)求的時(shí)間)
   
  proxy_send_timeout    5; // 后端服務(wù)器數(shù)據(jù)回傳時(shí)間_就是在規(guī)定時(shí)間之內(nèi)后端服務(wù)器必須傳完所有的數(shù)據(jù)
   
  proxy_buffer_size    16k; // 該指令設(shè)置緩沖區(qū)大小,從代理后端服務(wù)器取得的第一部分的響應(yīng)內(nèi)容,會(huì)放到這里,小的響應(yīng)header通常位于這部分響應(yīng)內(nèi)容里邊.(保存用戶頭信息的緩沖區(qū)大小)
   
  proxy_buffers      4 64k; // 該指令設(shè)置緩沖區(qū)的大小和數(shù)量,從被代理的后端服務(wù)器取得的響應(yīng)內(nèi)容,會(huì)放置到這里. 默認(rèn)情況下,一個(gè)緩沖區(qū)的大小等于內(nèi)存頁(yè)面大小,可能是4K也可能是8K,這取決于平臺(tái)
   
  proxy_busy_buffers_size 128k; // 有處在busy狀態(tài)的buffer size加起來(lái)不能超過proxy_busy_buffers_size,控制同時(shí)傳輸?shù)娇蛻舳说腷uffer數(shù)量的
   
  proxy_temp_file_write_size 128k; // # 臨時(shí)文件寫入大小
   
  # nginx和cgi之間的超時(shí)時(shí)間
  fastcgi_connect_timeout 90; 
  fastcgi_send_timeout 90;
  fastcgi_read_timeout 90;
  fastcgi_buffer_size 64k;
  fastcgi_buffers 4 64k;
  fastcgi_busy_buffers_size 128k;
  fastcgi_temp_file_write_size 128k;
 
  # 開啟gzip壓縮
  gzip on;
  gzip_min_length 1k;
  gzip_buffers   4 16k;
  # 對(duì)http/1.1協(xié)議的請(qǐng)求才會(huì)進(jìn)行壓縮,如果使用了反向代理,那么nginx和后端的upstream server服務(wù)器是使用的1.0協(xié)議通信
  gzip_http_version 1.1;
  gzip_comp_level 9;
  gzip_types    text/plain application/x-javascript text/css application/xml;
  gzip_vary on;
   
  # nginx緩存目錄(在location段落下需要配合proxy_store on 開啟緩存機(jī)制 include proxy.conf 處理的詳細(xì)規(guī)則 
  if (!-e $request_filename)){proxy_pass http://192.168.10.10;}
  
  proxy_temp_path  /data/wwwroot/proxy_temp_dir;
 
  #proxy_cache_path /data/wwwroot/cache.hxage.com levels=1:2  keys_zone=cache.hxage.com:3000m inactive=1y max_size=80G;
  # Nginx 內(nèi)部重定向規(guī)則會(huì)被啟動(dòng),當(dāng)URL 指向一個(gè)目錄并且在最后沒有包含“/”時(shí),Nginx 內(nèi)部會(huì)自動(dòng)的做一個(gè)301 重定向,這時(shí)會(huì)有兩種情況
  # 1、server_name_in_redirect on(默認(rèn)),URL 重定向?yàn)椋簊erver_name 中的第一個(gè)域名+ 目錄名+ /;
  # 2、server_name_in_redirect off,URL 重定向?yàn)椋涸璘RL 中的域名+ 目錄名+ /
  server_name_in_redirect off;
 
  server_tokens off;
 
  # sub filter
 
  # include sub_filter.conf;
 
  # null hostname
 
  server {
     listen 80 default;
     return 444;
     access_log off;
 }
server
{
    listen 5566;
    server_name localhost;
    index index.html index.htm index.shtml index.php;
    location ~ ^/status/
    {
        stub_status on;
        access_log off;
    }
}
#---------------- Vhost --------------------#
include vhost/*.conf;
}

# 以下時(shí)阿里云主機(jī)上的一段nginx.conf配置文件

user www www;
worker_processes auto;
 
error_log /alidata/log/nginx/error.log crit;
pid    /alidata/server/nginx/logs/nginx.pid;
 
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 65535;
 
events
{
 use epoll;
 worker_connections 65535;
}
 
 
http {
    include    mime.types;
    default_type application/octet-stream;
 
    #charset gb2312;
 
    server_names_hash_bucket_size 128;
    client_header_buffer_size 32k;
    large_client_header_buffers 4 32k;
    client_max_body_size 8m;
 
    sendfile on;
    tcp_nopush   on;
 
    keepalive_timeout 15;
 
    tcp_nodelay on;
 
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
    fastcgi_buffer_size 64k;
    fastcgi_buffers 4 64k;
    fastcgi_busy_buffers_size 128k;
    fastcgi_temp_file_write_size 128k;
 
    gzip on;
    gzip_min_length 1k;
    gzip_buffers   4 16k;
    gzip_http_version 1.1;
    gzip_comp_level 2;
    gzip_types    text/plain application/x-javascript text/css application/xml;
    gzip_vary on;
    gzip_disable msie6;
    #limit_zone crawler $binary_remote_addr 10m;
    log_format '$remote_addr - $remote_user [$time_local] "$request" '
           '$status $body_bytes_sent "$http_referer" '
           '"$http_user_agent" "$http_x_forwarded_for"';
    include /alidata/server/nginx/conf/vhosts/*.conf;
}

相關(guān)文章

最新評(píng)論