nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
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;
#keepalive_timeout 0;
keepalive_timeout 65;
server_tokens off;
gzip on;
server {
listen 80;
server_name _;
#charset koi8-r;
server_name_in_redirect off;
access_log /home/logs/www.abc.cn-access.log main;
location / {
root /home/site/cn/abc/www;
index index.html index.htm;
}
location ~* .*\.(js|css)?$
{
expires 7d;
access_log off;
}
location ~* .*\.(png|jpg|gif|jpeg|bmp|ico)?$
{
expires 7d;
access_log off;
}
location ~ /\.ht {
deny all;
}
}
include /usr/local/nginx/vhost/*;
}
vhost下面有两个配置文件:
a.conf 和 b.conf
a.conf:
server {
listen 80;
server_name a.abc.cn;
access_log /home/logs/a.abc.cn-access.log;
location / {
root /home/site/cn/abc/a/public;
index index.php index.html index.htm;
}
location ~* .*\.(js|css)?$
{
expires 7d;
access_log off;
}
location ~* .*\.(png|jpg|gif|jpeg|bmp|ico)?$
{
expires 7d;
access_log off;
}
location ~* .*\.(zip|rar|exe|msi|iso|gho|mp3|rmvb|mp4|wma|wmv|rm)?$
{
deny all;
}
}
b.conf
server {
listen 80;
server_name b.abc.cn;
access_log /home/logs/b.abc.cn-access.log;
location / {
root /home/site/cn/abc/b/public;
index index.php index.html index.htm;
}
location ~* .*\.(js|css)?$
{
expires 7d;
access_log off;
}
location ~* .*\.(png|jpg|gif|jpeg|bmp|ico)?$
{
expires 7d;
access_log off;
}
location ~* .*\.(zip|rar|exe|msi|iso|gho|mp3|rmvb|mp4|wma|wmv|rm)?$
{
deny all;
}
}
在/home/site/cn/abc/www,/home/site/cn/abc/a/public,/home/site/cn/abc/b/public下面均有index.html文件。。。但是访问这三个页面:www.abc.cn、a.abc.cn、b.abc.cn都是返回的nginx的默认页面welcome nginx。。。
请问我的配置文件哪里出了问题了么?
注:本来只有a.abc.cn和www.abc.cn的时候是可以正常访问的。但是加了一个b.abc.cn之后就出现了所有域名都指向默认页面的情况。
在增加b.abc.cn的时候,我只是在vhost中增加了一个b.conf的文件,其他均未改动。