Modify the Nginx rules for blocking web addresses

  • 2020-05-10 23:25:19
  • OfStack

Today to see the interview records, found that the volume of visits suddenly increased a lot, is it character explosion? A quick check of the source records shows:                  


  http://www.pinganxb.com/

  http://guanbao168.com/

  http://qifan123.com/

  http://zhixinshop.com/

  http://www.guanbao168.com

Then open, found that it had jumped to the home page of their own website, this is the pit, my host was malicious domain name to point to, that is, the empty host, quickly modify nginx.conf, and then add a paragraph of server; As follows:

         

server {
        listen       80  default;
        return       500;
    }

In this way, you can prevent others from visiting your website through ip or the domain name not specified by you, causing unnecessary trouble. If you are diligent enough, you can also complain to him. I don't have the energy to prove it.

If you feel like you're wasting traffic by redirecting it to your own site, he USES us, and we use them, redirecting it to the following, easy regular expressions:

     

 server {
    listen 80 default;
    rewrite ^(.*) http://www.dabu.info permanent;
    }

However, I found another problem. After the addition, I could access my website through www.ksharpdabu.info     or ksharpdabu.info, which means I could access the website through multiple domain names. Now I can only access it through the first domain name I designated. ksharpdabu.info is not available now. The solution is as follows:

     

server
    {
    listen 80 default;
    server_name _;
    return 500;
    }

Or:

             

 server {
        listen 80 dufault;
        server_name _;
        rewrite ^(.*) http://www.dabu.info permanent;
        }

After the second test, www.ksharpdabu.info and ksharpdabu.info were both accessible. By the way, I checked the whois of those malicious domain names, which were registered by the same Internet marketing company.


Related articles: