Stopping non-authorized domain

1 min read

To stop unauthorised domain pointing to the web server by showing an error 440 page.

For http page
vi /etc/nginx/conf.d/yourIPaddress.conf

server { 
listen your-ip:80 default; 
server_name _; 
#access_log /var/log/nginx/your-ip.log main; 
access_log /dev/null; 
error_log /dev/null; 
return 444; 
}

For https page

vi /etc/nginx/conf.d/https-default.conf

server { 
listen your-ip:443 default; 
server_name _; 
#access_log /var/log/nginx/your-ip.log main; 
ssl on; 
ssl_certificate /path/to/any/cert; 
ssl_certificate_key /path/to/any/cert;
access_log /dev/null; 
error_log /dev/null; 
return 444; 
}

save the file and restart services

service httpd restart
service nginx restart

Latest from Blog