当前位置 主页 > 服务器问题 > nginx问题汇总 >

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

    栏目:nginx问题汇总 时间:2019-07-17 10:25


    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;
      }
      }