@@ -29,44 +29,44 @@ worker_connections 65535;
2929#设定http服务器
3030http
3131{
32- include mime .types ; #文件扩展名与文件类型映射表
33- default_type application/ octet- stream; #默认文件类型
34- #charset utf- 8 ; #默认编码
35- server_names_hash_bucket_size 128 ; #服务器名字的hash表大小
36- client_header_buffer_size 32k ; #上传文件大小限制
37- large_client_header_buffers 4 64k ; #设定请求缓
38- client_max_body_size 8m ; #设定请求缓
39- sendfile on; #开启高效文件传输模式,sendfile指令指定nginx是否调用sendfile函数来输出文件,对于普通应用设为 on,如果用来进行下载等应用磁盘IO 重负载应用,可设置为off,以平衡磁盘与网络I / O 处理速度,降低系统的负载。注意:如果图片显示不正常把这个改成off。
40- autoindex on; #开启目录列表访问,合适下载服务器,默认关闭。
41- tcp_nopush on; #防止网络阻塞
42- tcp_nodelay on; #防止网络阻塞
43- keepalive_timeout 120 ; #长连接超时时间,单位是秒
44-
45- #FastCGI相关参数是为了改善网站的性能:减少资源占用,提高访问速度。下面参数看字面意思都能理解。
46- fastcgi_connect_timeout 300 ;
47- fastcgi_send_timeout 300 ;
48- fastcgi_read_timeout 300 ;
49- fastcgi_buffer_size 64k ;
50- fastcgi_buffers 4 64k ;
51- fastcgi_busy_buffers_size 128k ;
52- fastcgi_temp_file_write_size 128k ;
53-
54- #gzip模块设置
55- gzip on; #开启gzip压缩输出
56- gzip_min_length 1k ; #最小压缩文件大小
57- gzip_buffers 4 16k ; #压缩缓冲区
58- gzip_http_version 1.0 ; #压缩版本(默认1.1 ,前端如果是squid2.5 请使用1.0 )开始压缩的http协议版本(可以不设置,目前几乎全是1.1 协议)
59- gzip_comp_level 2 ; #推荐6 压缩级别(级别越高,压的越小,越浪费CPU 计算资源)
60- gzip_types text/ plain application/ x- javascript text/ css application/ xml;
61- #压缩类型,默认就已经包含text/ html,所以下面就不用再写了,写上去也不会有问题,但是会有一个warn。
62- gzip_vary on; # 是否传输gzip压缩标志
63- #limit_zone crawler $binary_remote_addr 10m ; #开启限制IP 连接数的时候需要使用
64-
65- upstream blog .ha97 .com {
66- #upstream的负载均衡,weight是权重,可以根据机器配置定义权重。weigth参数表示权值,权值越高被分配到的几率越大。
67- server 192.168 .80 .121 : 80 weight= 3 ;
68- server 192.168 .80 .122 : 80 weight= 2 ;
69- server 192.168 .80 .123 : 80 weight= 3 ;
32+ include mime .types ; #文件扩展名与文件类型映射表
33+ default_type application/ octet- stream; #默认文件类型
34+ #charset utf- 8 ; #默认编码
35+ server_names_hash_bucket_size 128 ; #服务器名字的hash表大小
36+ client_header_buffer_size 32k ; #上传文件大小限制
37+ large_client_header_buffers 4 64k ; #设定请求缓
38+ client_max_body_size 8m ; #设定请求缓
39+ sendfile on; #开启高效文件传输模式,sendfile指令指定nginx是否调用sendfile函数来输出文件,对于普通应用设为 on,如果用来进行下载等应用磁盘IO 重负载应用,可设置为off,以平衡磁盘与网络I / O 处理速度,降低系统的负载。注意:如果图片显示不正常把这个改成off。
40+ autoindex on; #开启目录列表访问,合适下载服务器,默认关闭。
41+ tcp_nopush on; #防止网络阻塞
42+ tcp_nodelay on; #防止网络阻塞
43+ keepalive_timeout 120 ; #长连接超时时间,单位是秒
44+
45+ #FastCGI相关参数是为了改善网站的性能:减少资源占用,提高访问速度。下面参数看字面意思都能理解。
46+ fastcgi_connect_timeout 300 ;
47+ fastcgi_send_timeout 300 ;
48+ fastcgi_read_timeout 300 ;
49+ fastcgi_buffer_size 64k ;
50+ fastcgi_buffers 4 64k ;
51+ fastcgi_busy_buffers_size 128k ;
52+ fastcgi_temp_file_write_size 128k ;
53+
54+ #gzip模块设置
55+ gzip on; #开启gzip压缩输出
56+ gzip_min_length 1k ; #最小压缩文件大小
57+ gzip_buffers 4 16k ; #压缩缓冲区
58+ gzip_http_version 1.0 ; #压缩版本(默认1.1 ,前端如果是squid2.5 请使用1.0 )开始压缩的http协议版本(可以不设置,目前几乎全是1.1 协议)
59+ gzip_comp_level 2 ; #推荐6 压缩级别(级别越高,压的越小,越浪费CPU 计算资源)
60+ gzip_types text/ plain application/ x- javascript text/ css application/ xml;
61+ #压缩类型,默认就已经包含text/ html,所以下面就不用再写了,写上去也不会有问题,但是会有一个warn。
62+ gzip_vary on; # 是否传输gzip压缩标志
63+ #limit_zone crawler $binary_remote_addr 10m ; #开启限制IP 连接数的时候需要使用
64+
65+ upstream blog .ha97 .com {
66+ #upstream的负载均衡,weight是权重,可以根据机器配置定义权重。weigth参数表示权值,权值越高被分配到的几率越大。
67+ server 192.168 .80 .121 : 80 weight= 3 ;
68+ server 192.168 .80 .122 : 80 weight= 2 ;
69+ server 192.168 .80 .123 : 80 weight= 3 ;
7070}
7171
7272#虚拟主机的配置
@@ -78,22 +78,26 @@ server
7878 server_name www .ha97 .com ha97 .com ;
7979 index index .html index .htm index .php ;
8080 root / data/ www/ ha97;
81+
8182 location ~ .* \.(php| php5)? $
8283 {
83- fastcgi_pass 127.0 .0 .1 : 9000 ;
84- fastcgi_index index .php ;
85- include fastcgi .conf ;
84+ fastcgi_pass 127.0 .0 .1 : 9000 ;
85+ fastcgi_index index .php ;
86+ include fastcgi .conf ;
8687 }
88+
8789 #图片缓存时间设置
8890 location ~ .* \.(gif| jpg| jpeg| png| bmp| swf)$
8991 {
90- expires 10d ;
92+ expires 10d ;
9193 }
94+
9295 #JS 和CSS 缓存时间设置
9396 location ~ .* \.(js| css)? $
9497 {
95- expires 1h ;
98+ expires 1h ;
9699 }
100+
97101 #日志格式设定
98102 log_format access ' $remote_addr - $remote_user [$time_local] "$request" '
99103 ' $status $body_bytes_sent "$http_referer" '
@@ -103,48 +107,53 @@ server
103107
104108 #对 " /" 启用反向代理
105109 location / {
106- proxy_pass http: // 127.0.0.1:88;
107- proxy_redirect off;
108- proxy_set_header X - Real- IP $remote_addr;
109- #后端的Web服务器可以通过X - Forwarded- For获取用户真实IP
110- proxy_set_header X - Forwarded- For $proxy_add_x_forwarded_for;
111- #以下是一些反向代理的配置,可选。
112- proxy_set_header Host $host;
113- client_max_body_size 10m ; #允许客户端请求的最大单文件字节数
114- client_body_buffer_size 128k ; #缓冲区代理缓冲用户端请求的最大字节数,
115- proxy_connect_timeout 90 ; #nginx跟后端服务器连接超时时间(代理连接超时)
116- proxy_send_timeout 90 ; #后端服务器数据回传时间(代理发送超时)
117- proxy_read_timeout 90 ; #连接成功后,后端服务器响应时间(代理接收超时)
118- proxy_buffer_size 4k ; #设置代理服务器(nginx)保存用户头信息的缓冲区大小
119- proxy_buffers 4 32k ; #proxy_buffers缓冲区,网页平均在32k 以下的设置
120- proxy_busy_buffers_size 64k ; #高负荷下缓冲大小(proxy_buffers* 2 )
121- proxy_temp_file_write_size 64k ;
122- #设定缓存文件夹大小,大于这个值,将从upstream服务器传
110+ proxy_pass http: // 127.0.0.1:88;
111+ proxy_redirect off;
112+ proxy_set_header X - Real- IP $remote_addr;
113+ #后端的Web服务器可以通过X - Forwarded- For获取用户真实IP
114+ proxy_set_header X - Forwarded- For $proxy_add_x_forwarded_for;
115+ #以下是一些反向代理的配置,可选。
116+ proxy_set_header Host $host;
117+ client_max_body_size 10m ; #允许客户端请求的最大单文件字节数
118+ client_body_buffer_size 128k ; #缓冲区代理缓冲用户端请求的最大字节数,
119+ proxy_connect_timeout 90 ; #nginx跟后端服务器连接超时时间(代理连接超时)
120+ proxy_send_timeout 90 ; #后端服务器数据回传时间(代理发送超时)
121+ proxy_read_timeout 90 ; #连接成功后,后端服务器响应时间(代理接收超时)
122+ proxy_buffer_size 4k ; #设置代理服务器(nginx)保存用户头信息的缓冲区大小
123+ proxy_buffers 4 32k ; #proxy_buffers缓冲区,网页平均在32k 以下的设置
124+ proxy_busy_buffers_size 64k ; #高负荷下缓冲大小(proxy_buffers* 2 )
125+ proxy_temp_file_write_size 64k ;
126+ #设定缓存文件夹大小,大于这个值,将从upstream服务器传
123127 }
124128
125129 #设定查看Nginx状态的地址
126130 location / NginxStatus {
127- stub_status on;
128- access_log on;
129- auth_basic " NginxStatus" ;
130- auth_basic_user_file conf/ htpasswd;
131- #htpasswd文件的内容可以用apache提供的htpasswd工具来产生。
131+ stub_status on;
132+ access_log on;
133+ auth_basic " NginxStatus" ;
134+ auth_basic_user_file conf/ htpasswd;
135+ #htpasswd文件的内容可以用apache提供的htpasswd工具来产生。
132136 }
133137
134138 #本地动静分离反向代理配置
135139 #所有jsp的页面均交由tomcat或resin处理
136140 location ~ .(jsp| jspx| do )? $ {
137- proxy_set_header Host $host;
138- proxy_set_header X - Real- IP $remote_addr;
139- proxy_set_header X - Forwarded- For $proxy_add_x_forwarded_for;
140- proxy_pass http: // 127.0.0.1:8080;
141+ proxy_set_header Host $host;
142+ proxy_set_header X - Real- IP $remote_addr;
143+ proxy_set_header X - Forwarded- For $proxy_add_x_forwarded_for;
144+ proxy_pass http: // 127.0.0.1:8080;
141145 }
146+
142147 #所有静态文件由nginx直接读取不经过tomcat或resin
143148 location ~ .* .(htm| html| gif| jpg| jpeg| png| bmp| swf| ioc| rar| zip| txt| flv| mid| doc| ppt| pdf| xls| mp3| wma)$
144- { expires 15d ; }
149+ {
150+ expires 15d ;
151+ }
145152 location ~ .* .(js| css)? $
146- { expires 1h ; }
147- }
153+ {
154+ expires 1h ;
155+ }
156+ }
148157}
149158
150159` ` `
0 commit comments