1、添加server_name为空或者localhost
server {
listen 80;
server_name localhost;
location / {
if ($host —— localhost) {
return 403;
}
}
}
2、添加server_name为yourdns
server
{
access_log /data/logs/nginx/access.log;
listen 80;
server_name yourdns;
charset utf-8;
root /data/www;
index index.html index.htm index.php;
location / {
expires 1d;
}
}