By Proton coder
We can disable direct visiting on website with its server IP address with below method —>
ServerName 1.2.3.4
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Location />
Order Allow,Deny
Deny from All
</Location>
but it can still visit-able with https://1.2.3.4… . Can any one please tell how to prevent visits with http://1.2.3.4 and https://1.2.3.4
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi @metaproton1,
Depending on the WebService you are using the answer varies. If you are using Apache as a WebService you can use the following way:
Additionally, this mini tutorial will be for Ubuntu. If you are using CentOS let me know and I’ll provide steps for it as well :
You’ll need to create a virtual configuration - Vhost. Create a new config file in the sites-available directory:
sudo nano /etc/apache2/sites-available/direct.conf
In the file add the following :
<VirtualHost *:80>
ServerName xxx.xxx.xxx.xxx
Redirect 403
DocumentRoot /path/to/file
</VirtualHost>
You’ll need to change the xxx.xxx.xxx.xxx with your actual IP address and the /path/to/file with the path to the file being the file you wish people to see when they access the IP address. Once you have saved the file, type
sudo a2ensite direct
and restart your server:
sudo apache2 restart
That’s it, you’ve now redirected access of your IP address to a certain file.
If you wish to completly deny it, add the DocumentRoot to be /dev/null
You can add this server block to your configuration.
server {
listen 80 default_server;
server_name "";
return 444;
}
You need to specify “default_server” parameter so that all non available server requests goes to this server block which throws 444 error. The “default_server” parameter cannot be present in any other server block.
444 : CONNECTION CLOSED WITHOUT RESPONSE
Regards, KDSys
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.