nginx设置禁止通过IP直接访问服务器

2019-10-04

nginx.conf 

http 里面添加

server {
  listen 80 default;
          listen [::]:80 default;
  server_name _;
  return 500;
}
server {
  listen 443 default;
          listen [::]:443 default;
            ssl_certificate /etc/nginx/ssl/a.crt;
        ssl_certificate_key /etc/nginx/ssl/b.key;
  server_name _;
  return 500;
}

如下

image