首页 > 网站 > Nginx > 正文

nginx怎么配置IP和域名都能访问?

2024-08-30 12:23:42
字体:
来源:转载
供稿:网友

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;
  }
  }
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表