How to disable IP access to my server

Linux uses Apache's virtual host mechanism, access to the first virtual host without a bound domain name or ip direct access

Note: The following operations require remote login ssh to execute commands.

Centos-default apache:

Edit configuration file

Vi /etc/httpd/conf/httpd.conf

Add a virtual host configuration arbitrarily under NameVirtualHost *:80, such as

<VirtualHost *:80>

DocumentRoot "/var/www/html"

ServerName www.test.com

<Directory "/var/www/html">

Deny from all

</Directory>

</VirtualHost>

Restart the service

Service httpd restart

Centos-wd:

Just delete one file

Rm -f /www/web/default/index.php

Ubuntu:

Vi /etc/apache2/ports.conf

Add a virtual host configuration arbitrarily under NameVirtualHost *:80, such as

<VirtualHost *:80>

DocumentRoot "/var/www/html"

ServerName www.test.com

<Directory "/var/www/html">

Deny from all

</Directory>

</VirtualHost>

Restart the service

/etc/init.d/apache2 restart

 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to choose the cloud server?

★ Choose the right cloud server configuration based on your actual business needs: Understand...

How do I connect to my cloud server? (including linux and windows)

First of all to distinguish between linux and windows, including ubuntu, centos, debian are...

linux system data disk merged into the system disk

 Check it out, the current command: df -h [[email protected] ~]# df -h Filesystem...

Linux cloud server data disk expansion tutorial guide

This tutorial belongs to the data disk expansion [non-system disk] default directory /dev/sdb...

About the automatic synchronization of cloud server time, and the problem that time cannot be modified.

Recently, there have been user feedback, cloud server time cannot be modified. The solution is...