Web site prohibits server IP access in Apache environment

Source: Internet
Author: User

In our web site can actually be accessed via IP directly, of course, in our testing is convenient, but once in the actual production server so allow IP direct access to the source site is a dangerous move, if your production server is malicious binding, traffic hijacked to another domain name, Will be banned by the Ad alliance. Because your domain name can be accessed through the IP, if the malicious use of domain name resolution to your IP, your site can be accessed through someone else's domain name, time a long ad alliance found that domain name and IP does not meet the blocked, and so others to bind your IP to other malicious domain name is also very dangerous. So we can use Apache rewrite and PHP implementation 403 error To disable the direct use of IP access to your site

Set up a host configuration on your virtual host to access rewrite custom PHP pages from IP

<virtualhost *:80> documentroot "/data/www/error" #自定义的php页面目录 ServerName XX. Xx. Xx. xx# IP available on the server <Directory/data/www/error> allowoverride all Rewriteengine on# This must be open Orde R Allow,deny allow from all </Directory></VirtualHost>

Then we build a simple PHP file in the/data/www/error directory, using 403.php

[[email protected] ERROR] #vim 403.php<?phpheader ("http/1.1 403 Bad Request"); ?>

And then we'll restart Apache.

This article from the "Technical essay" blog, reproduced please contact the author!

Disable server IP access for Web sites under the Apache environment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.