作者:实圪垯电动乐园_855 | 来源:互联网 | 2014-05-28 09:40
server{listen202.***.***.***:80;#换成你的IP地址client_max_body_size100M;server_namewww.test.com;#换成你的域名charsetgb2312;indexindex.htmlindex.htmindex.php;root/host/wwwro
server {
listen
202.***.***.***:80; #换成你的IP地址
client_max_body_size 100M;
server_name www.test.com; #换成你的域名
charset gb2312;
index index.html index.htm index.php;
root
/host/wwwroot/test;
#你的站点路径
#打开目录浏览,这样当没有找到index文件,就也已浏览目录中的文件
autoindex on;
if (-d
$request_filename) {
rewrite ^/(.*)([^/])$ http://$host/$1$2/
permanent;
}
error_page 404 /404.html;
location = /40x.html {
root /host/wwwroot/test;
#你的站点路径
charset on;
}
# redirect server error pages to the static page /50x.html
#
error_page 500
502 503
504 /50x.html;
location = /50x.html {
root
/host/wwwroot/test; #你的站点路径
charset on;
}
#将客户端的请求转交给fastcgi
location ~
.*\.(php|php5|php4|shtml|xhtml|phtml)?$ {
fastcgi_pass
127.0.0.1:9000;
include
/host/
nginx/conf/fastcgi_params;
}
#网站的图片较多,更改较少,将它们在浏览器本地缓存15天
location ~
.*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 15d;
}
#网站会加载很多JS、CSS,将它们在浏览器本地缓存1天
location ~ .*\.(js|css)?$
{
expires 1d;
}
location /(WEB-INF)/ {
deny all;
}
#设定日志格式
log_format access '$remote_addr -
$remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer"
'
'"$http_user_agent"
$http_x_forwarded_for';
#设定本虚拟主机的访问日志
access_log /host/nginx/logs/down/access.log access;
#日志的路径,每个虚拟机一个,不能相同
server_name_in_redirect off;
}