How to disable Apache and nginx empty host headers under Linux system

  
                  In order to prevent malicious domain name resolution, we need to disable the default empty host header of apache. The operation is as follows: vi /etc/httpd/conf/httpd.conf Edit the configuration file, add a site before your site configuration (the red font part is We want to add, the blue font part represents the site configuration you are using) NameVirtualHost *<VirtualHost *:80>ServerAdmin yourmail#mail.comDocumentRoot /errorServerName abc.com</VirtualHost><VirtualHost *:80>ServerAdmin yourmail #mail.comDocumentRoot "your site path"ServerName yourWebsite.comServerAlias ​​*.yourWebsite.com</VirtualHost>Unlocking nginx empty host headers under Linux Introduction: In order to prevent malicious domain name resolution, we need to disable nginx default The empty host header, the operation is as follows
vi /usr/local/nginx/conf/nginx.conf #Configuration file find the server, add the following two lines: listen 80 default; #default represents the default virtual host server_name _;; for example: Server {listen 80 default;server_name _;return 500; #return 500 error message} You can also turn these empty traffic to a website, as follows:
server {listen 80 default;server_name _;rewrite ^(.*) http://a URL permanent; #page redirection }
Copyright © Windows knowledge All Rights Reserved