Nginx 프로필 상용 부분 설명

17383 단어 nginx
원문
  1 #  Nginx         

  2 user www www;

  3 #nginx   ,       CPU    。

  4 worker_processes 8;

  5 #          ,[ debug | info | notice | warn | error | crit ]

  6 error_log /var/log/nginx/error.log info;

  7 #    

  8 pid /var/run/nginx.pid;

  9 #  nginx              ,             (    ulimit -n) nginx     ,  nginx        ,     ulimit -n      。

 10 worker_rlimit_nofile 65535;

 11 #          

 12 events

 13 {

 14     #      ,use [ kqueue | rtsig | epoll | /dev/poll | select | poll ]; epoll   Linux 2.6             I/O  ,    FreeBSD  ,  kqueue  。

 15     use epoll;

 16     #         (     =   * 17     worker_connections 65535;

 18 }

 19 #  http   

 20 http

 21 {

 22     include mime.types; #             

 23     default_type application/octet-stream; #      

 24     #charset utf-8; #    

 25     server_names_hash_bucket_size 128; #      hash   

 26     client_header_buffer_size 32k; #        

 27     large_client_header_buffers 4 64k; #     

 28     client_max_body_size 8m; #     

 29     sendfile on; #          ,sendfile    nginx    sendfile       ,         on,             IO     ,    off,        I/O    ,       。  :              off。

 30     autoindex on; #        ,       ,    。

 31     tcp_nopush on; #      

 32     tcp_nodelay on; #      

 33     keepalive_timeout 120; #       ,    

 34     #FastCGI              :      ,      。             。

 35     fastcgi_connect_timeout 300;

 36     fastcgi_send_timeout 300;

 37     fastcgi_read_timeout 300;

 38     fastcgi_buffer_size 64k;

 39     fastcgi_buffers 4 64k;

 40     fastcgi_busy_buffers_size 128k;

 41     fastcgi_temp_file_write_size 128k;

 42     #gzip    

 43     gzip on; #  gzip    

 44     gzip_min_length 1k; #        

 45     gzip_buffers 4 16k; #     

 46     gzip_http_version 1.0; #    (  1.1,     squid2.5   1.0 47     gzip_comp_level 2; #    

 48     gzip_types text/plain application/x-javascript text/css application/xml;

 49     #    ,       text/html,          ,         ,      warn。

 50     gzip_vary on;

 51     #limit_zone crawler $binary_remote_addr 10m; #    IP          

 52     upstream blog.ha97.com {

 53         #upstream     ,weight   ,            。weigth      ,             。

 54         server 192.168.80.121:80 weight=3;

 55         server 192.168.80.122:80 weight=2;

 56         server 192.168.80.123:80 weight=3;

 57     }

 58     #       

 59     server

 60     {

 61         #    

 62         listen 80;

 63         #       ,     

 64         server_name www.ha97.com ha97.com;

 65         index index.html index.htm index.php;

 66         root /data/www/ha97;

 67         location ~ .*.(php|php5)?$

 68         {

 69             fastcgi_pass 127.0.0.1:9000;

 70             fastcgi_index index.php;

 71             include fastcgi.conf;

 72         }

 73         #        

 74         location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$

 75         {

 76             expires 10d;

 77         }

 78         #JS CSS      

 79         location ~ .*.(js|css)?$

 80         {

 81             expires 1h;

 82         }

 83         #      

 84         log_format access '$remote_addr - $remote_user [$time_local] "$request" '

 85         '$status $body_bytes_sent "$http_referer" '

 86         '"$http_user_agent" $http_x_forwarded_for';

 87         #            

 88         access_log /var/log/nginx/ha97access.log access;

 89         #  "/"       

 90         location / {

 91             proxy_pass http://127.0.0.1:88;

 92             proxy_redirect off;

 93             proxy_set_header X-Real-IP $remote_addr;

 94             #   Web       X-Forwarded-For      IP

 95             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

 96             #            ,  。

 97             proxy_set_header Host $host;

 98             client_max_body_size 10m; #                

 99             client_body_buffer_size 128k; #                  ,

100             proxy_connect_timeout 90; #nginx            (      )

101             proxy_send_timeout 90; #           (      )

102             proxy_read_timeout 90; #     ,         (      )

103             proxy_buffer_size 4k; #       (nginx)             

104             proxy_buffers 4 32k; #proxy_buffers   ,     32k     

105             proxy_busy_buffers_size 64k; #        (proxy_buffers*2106             proxy_temp_file_write_size 64k;

107             #         ,     ,  upstream    

108         }

109         #    Nginx     

110         location /NginxStatus {

111             stub_status on;

112             access_log on;

113             auth_basic "NginxStatus";

114             auth_basic_user_file conf/htpasswd;

115             #htpasswd        apache   htpasswd     。

116         }

117         #            

118         #  jsp      tomcat resin  

119         location ~ .(jsp|jspx|do)?$ {

120             proxy_set_header Host $host;

121             proxy_set_header X-Real-IP $remote_addr;

122             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

123             proxy_pass http://127.0.0.1:8080;

124         }

125         #       nginx       tomcat resin

126         location ~ .*.(htm|html|gif|jpg|jpeg|png|bmp|swf|ioc|rar|zip|txt|flv|mid|doc|ppt|pdf|xls|mp3|wma)$

127         { expires 15d; }

128         location ~ .*.(js|css)?$

129         { expires 1h; }

130     }

131 }

좋은 웹페이지 즐겨찾기