用 nginx -t 检测配置文件会提示warning:
[warn]: conflicting server name “abc.com” on 0.0.0.0:80, ignored
the configuration file /usr/local/webserver/nginx/conf/nginx.conf syntax is ok
configuration file /usr/local/webserver/nginx/conf/nginx.conf test is successful
最后通过在listen 80 default;后再加server_name _;解决,形式如下:
#禁止IP访问
server
{
listen 80 default;
server_name _;
return 500;
}
这样,通过abc.com就能访问服务器了,问题是解决了,但具体原因还是不清楚。