第一种:
返回HTTP 状态码
-
server { -
listen 80 default; -
server_name _; -
return 403; -
}
default表示默认主机
403为Http状态码,可根据需要修改
这样可以屏蔽所有域名(除了你自己绑定的)和IP的访问。
我们也可以吧return 403;改成重定向,把非法访问重定向到其他地址
第二种:
-
server { -
listen 80 default; -
server_name _; -
rewrite ^(.*) http://www.baidu.com permanent; -
}
改成重定向,把非法访问重定向到其他地址
例子:如下为Nginx.conf的配置
-
####################################################################### -
# -
# This is the main Nginx configuration file. -
# -
# More information about the configuration options is available on -
# * the English wiki - http://wiki.nginx.org/Main -
# * the Russian documentation - http://sysoev.ru/nginx/ -
# -
####################################################################### -
#---------------------------------------------------------------------- -
# Main Module - directives that cover basic functionality -
# -
# http://wiki.nginx.org/NginxHttpMainModule -
# -
#---------------------------------------------------------------------- -
user nginx; -
#worker_processes 16; -
worker_processes 4; -
######add parameter###### -
worker_rlimit_nofile 65535; -
######end add ########### -
error_log /var/log/nginx/error.log; -
#error_log /var/log/nginx/error.log notice; -
#error_log /var/log/nginx/error.log info; -
pid /var/run/nginx.pid; -
#---------------------------------------------------------------------- -
# Events Module -
# -
# http://wiki.nginx.org/NginxHttpEventsModule -
# -
#---------------------------------------------------------------------- -
events { -
#####add parameter ##### -
use epoll; -
worker_connections 65535; -
#####end add ########### -
#worker_connections 1024; -
} -
#---------------------------------------------------------------------- -
# HTTP Core Module -
# -
# http://wiki.nginx.org/NginxHttpCoreModule -
# -
#---------------------------------------------------------------------- -
http { -
include /etc/nginx/mime.types; -
default_type application/octet-stream; -
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' -
'$status $body_bytes_sent "$http_referer" ' -
'"$http_user_agent" "$http_x_forwarded_for"'; -
access_log /var/log/nginx/access.log main; -
sendfile on; -
tcp_nopush on; -
server_names_hash_bucket_size 512; -
#keepalive_timeout 0; -
keepalive_timeout 300; -
tcp_nodelay on; ######add file -
fastcgi_connect_timeout 300s; -
fastcgi_send_timeout 300s; -
fastcgi_read_timeout 300s; -
fastcgi_buffer_size 64k; -
fastcgi_buffers 4 32k; -
fastcgi_busy_buffers_size 64k; -
fastcgi_temp_file_write_size 64k; -
#gzip on; -
# Load config files from the /etc/nginx/conf.d directory -
# The default server is in conf.d/default.conf -
client_header_buffer_size 128k; #####add file -
large_client_header_buffers 4 128k; #####add file -
server{ -
listen 80 default; -
rewrite ^(.*) http://ifengniu.com permanent; -
} -
include /etc/nginx/conf.d/*.conf; -
include sites-enabled/*; -
}
最后
以上就是俊秀音响最近收集整理的关于域名泛解析后nginx拒绝未绑定域名的全部内容,更多相关域名泛解析后nginx拒绝未绑定域名内容请搜索靠谱客的其他文章。
发表评论 取消回复