配置nginx禁止ip直接访问

官方文档中提供的方法:
If you do not want to process requests with undefined “Host” header lines, you may define a default server that just drops the requests:

server {
        listen 80 default_server;
        server_name _;
        return 444;
}

只要是访客用ip访问就直接重置444错误,这样好像又不太友好,如果能直接给跳转到某个域名就好了。
配置如下:

server {
        listen       80 default_server;
        server_name _;
        rewrite ^(.*) http://www.btnotes.com permanent;
}
  1. 暂无评论

  1. 暂无 Trackback

return top